www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Strange gtkd behaviour

reply maarten van damme <maartenvd1994 gmail.com> writes:
--00504502cd05c8f01304a7f9b47f
Content-Type: text/plain; charset=ISO-8859-1

Hello everyone,
I wrote two classes that inherit from the Mainwindow class, one is a dialog
that asks for your input and one is a plain old messagebox.
you can check out the input class here, I think thats the one with the
problem: http://dl.dropbox.com/u/15024434/InputBox.d
or read the method most likely containing the error:
void onclicked(Button button){
*answer=input.getText();
destroy();
Main.quit();
 }

Then I have a main class where I create an inputbox and do Main.run(), then
when the user closes the window or presses ok everything after the first
main.run gets runned and that displays a messagebox that depends on what the
user entered followed by another Main.run();

The problem is that when you press ok to close the first input window and
then close the next messagebox the program keeps running in memory.
Everything after the second Main.run never gets executed. When you however
close the first window using the close button and then close the next
messagebox the program terminates correctly.
I'm assuming I don't completely destroy the inputbox in the onclicked
method?

If what I gave you is not enough I can give you the links to all the files.
Note that these classes are simply me learning gtkd and the d language in
general. If you see me doing something "dirty" or bad please tell me so I
learn a bit from my mistakes :)

Maarten

--00504502cd05c8f01304a7f9b47f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello everyone,<div>I wrote two classes that inherit from the Mainwindow cl=
ass, one is a dialog that asks for your input and one is a plain old messag=
ebox.</div><div>you can check out the input class here, I think thats the o=
ne with the problem:=A0<a href=3D"http://dl.dropbox.com/u/15024434/InputBox=
.d">http://dl.dropbox.com/u/15024434/InputBox.d</a></div>
<div>or read the method most likely containing the error:</div><div><div><s=
pan class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>void onclick=
ed(Button button){</div><div><span class=3D"Apple-tab-span" style=3D"white-=
space:pre">		</span>*answer=3Dinput.getText();</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</span>dest=
roy();</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	=
	</span>Main.quit();</div><div><span class=3D"Apple-tab-span" style=3D"whit=
e-space:pre">		</span></div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>}</di=
v></div><div><br></div><div>Then I have a main class where I create an inpu=
tbox and do Main.run(), then when the user closes the window or presses ok =
everything after the first main.run gets runned and that displays a message=
box that depends on what the user entered followed by another Main.run();</=
div>
<div><br></div><div>The problem is that when you press ok to close the firs=
t input window and then close the next messagebox the program keeps running=
 in memory. Everything after the second Main.run never gets executed. When =
you however close the first window using the close button and then close th=
e next messagebox the program terminates correctly.</div>
<div>I&#39;m assuming I don&#39;t completely destroy the inputbox in the on=
clicked method?</div><div><br></div><div>If what I gave you is not enough I=
 can give you the links to all the files. Note that these classes are simpl=
y me learning gtkd and the d language in general. If you see me doing somet=
hing &quot;dirty&quot; or bad please tell me so I learn a bit from my mista=
kes :)</div>
<div><br></div><div>Maarten</div>

--00504502cd05c8f01304a7f9b47f--
Jul 13 2011
next sibling parent reply Mike Wey <mike-wey example.com> writes:
On 07/13/2011 11:00 PM, maarten van damme wrote:
 Hello everyone,
 I wrote two classes that inherit from the Mainwindow class, one is a
 dialog that asks for your input and one is a plain old messagebox.
 you can check out the input class here, I think thats the one with the
 problem: http://dl.dropbox.com/u/15024434/InputBox.d
 or read the method most likely containing the error:
 void onclicked(Button button){
 *answer=input.getText();
 destroy();
 Main.quit();
 }

 Then I have a main class where I create an inputbox and do Main.run(),
 then when the user closes the window or presses ok everything after the
 first main.run gets runned and that displays a messagebox that depends
 on what the user entered followed by another Main.run();

 The problem is that when you press ok to close the first input window
 and then close the next messagebox the program keeps running in memory.
 Everything after the second Main.run never gets executed. When you
 however close the first window using the close button and then close the
 next messagebox the program terminates correctly.
 I'm assuming I don't completely destroy the inputbox in the onclicked
 method?

 If what I gave you is not enough I can give you the links to all the
 files. Note that these classes are simply me learning gtkd and the d
 language in general. If you see me doing something "dirty" or bad please
 tell me so I learn a bit from my mistakes :)

 Maarten

I'm not sure if the Main.Quit gets executed after you've destroyed the InputBox, does it work correctly without the call to destroy? If not links to the other files would be helpfull. -- Mike Wey
Jul 13 2011
parent Mike Wey <mike-wey example.com> writes:
On 07/14/2011 07:53 AM, maarten van damme wrote:
 when I leave destroy out the inputbox always stays visible even after
 I've pressed ok.
 here are the other files
 http://dl.dropbox.com/u/15024434/Main.d
 http://dl.dropbox.com/u/15024434/InputBox.d
 http://dl.dropbox.com/u/15024434/MessageBox.d

I see you are calling Main.run twice, although you would only call it once it will work. But you'll also need to call Main.Quit twice, probably when the second 'Messagebox' is closed. This is because Main.run() runs the gtk eventloop and returns when Main.Quit is called. Yoe might also want to look at gtk.Dialog and gtk.MessageDialog for your "InputBox" and "MessageBox" respectively. gtk.Dialog has it's own run method which returns a response code when the user closes the dialog, by clicking ok/cancel/etc... or just closes it. -- Mike Wey
Jul 14 2011
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--00504502c6d398140104a80125a1
Content-Type: text/plain; charset=ISO-8859-1

when I leave destroy out the inputbox always stays visible even after I've
pressed ok.
here are the other files
http://dl.dropbox.com/u/15024434/Main.d
http://dl.dropbox.com/u/15024434/InputBox.d
http://dl.dropbox.com/u/15024434/MessageBox.d

 On 07/13/2011 11:00 PM, maarten van damme wrote:

 Hello everyone,
 I wrote two classes that inherit from the Mainwindow class, one is a
 dialog that asks for your input and one is a plain old messagebox.
 you can check out the input class here, I think thats the one with the
 problem: http://dl.dropbox.com/u/**15024434/InputBox.d<http://dl.dropbox.com/u/15024434/InputBox.d>
 or read the method most likely containing the error:
 void onclicked(Button button){
 *answer=input.getText();
 destroy();
 Main.quit();
 }

 Then I have a main class where I create an inputbox and do Main.run(),
 then when the user closes the window or presses ok everything after the
 first main.run gets runned and that displays a messagebox that depends
 on what the user entered followed by another Main.run();

 The problem is that when you press ok to close the first input window
 and then close the next messagebox the program keeps running in memory.
 Everything after the second Main.run never gets executed. When you
 however close the first window using the close button and then close the
 next messagebox the program terminates correctly.
 I'm assuming I don't completely destroy the inputbox in the onclicked
 method?

 If what I gave you is not enough I can give you the links to all the
 files. Note that these classes are simply me learning gtkd and the d
 language in general. If you see me doing something "dirty" or bad please
 tell me so I learn a bit from my mistakes :)

 Maarten

I'm not sure if the Main.Quit gets executed after you've destroyed the InputBox, does it work correctly without the call to destroy? If not links to the other files would be helpfull. -- Mike Wey

--00504502c6d398140104a80125a1 Content-Type: text/html; charset=ISO-8859-1 when I leave destroy out the inputbox always stays visible even after I&#39;ve pressed ok.<div>here are the other files</div><div><a href="http://dl.dropbox.com/u/15024434/Main.d">http://dl.dropbox.com/u/15024434/Main.d</a></div> <div><a href="http://dl.dropbox.com/u/15024434/InputBox.d">http://dl.dropbox.com/u/15024434/InputBo .d</a></div><div><a href="http://dl.dropbox.com/u/15024434/MessageBox.d">http://dl.dropbox.com/u/15024434/MessageBox.d</a><br> <div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5">On 07/13/2011 11:00 PM, maarten van damme wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hello everyone,<br> I wrote two classes that inherit from the Mainwindow class, one is a<br> dialog that asks for your input and one is a plain old messagebox.<br> you can check out the input class here, I think thats the one with the<br> problem: <a href="http://dl.dropbox.com/u/15024434/InputBox.d" target="_blank">http://dl.dropbox.com/u/<u></u>15024434/InputBox.d</a><br> or read the method most likely containing the error:<br> void onclicked(Button button){<br> *answer=input.getText();<br> destroy();<br> Main.quit();<br> }<br> <br> Then I have a main class where I create an inputbox and do Main.run(),<br> then when the user closes the window or presses ok everything after the<br> first main.run gets runned and that displays a messagebox that depends<br> on what the user entered followed by another Main.run();<br> <br> The problem is that when you press ok to close the first input window<br> and then close the next messagebox the program keeps running in memory.<br> Everything after the second Main.run never gets executed. When you<br> however close the first window using the close button and then close the<br> next messagebox the program terminates correctly.<br> I&#39;m assuming I don&#39;t completely destroy the inputbox in the onclicked<br> method?<br> <br> If what I gave you is not enough I can give you the links to all the<br> files. Note that these classes are simply me learning gtkd and the d<br> language in general. If you see me doing something &quot;dirty&quot; or bad please<br> tell me so I learn a bit from my mistakes :)<br> <br> Maarten<br> </blockquote> <br></div></div> I&#39;m not sure if the Main.Quit gets executed after you&#39;ve destroyed the InputBox, does it work correctly without the call to destroy?<br> <br> If not links to the other files would be helpfull.<br> <br> -- <br><font color="#888888"> Mike Wey<br> </font></blockquote></div><br></div> --00504502c6d398140104a80125a1--
Jul 13 2011
prev sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--000e0cd32c287b607204a80e5ec3
Content-Type: text/plain; charset=ISO-8859-1

Thanks a lot for clarifying it for me. It runs perfectly now.
I should've used gtk.(message)dialog but I got terribly lost in the gtk
documentation and so I missed it.


2011/7/14 Mike Wey <mike-wey example.com>

 On 07/14/2011 07:53 AM, maarten van damme wrote:

 when I leave destroy out the inputbox always stays visible even after
 I've pressed ok.
 here are the other files
 http://dl.dropbox.com/u/**15024434/Main.d<http://dl.dropbox.com/u/15024434/Main.d>

 http://dl.dropbox.com/u/**15024434/InputBox.d<http://dl.dropbox.com/u/15024434/InputBox.d>
 http://dl.dropbox.com/u/**15024434/MessageBox.d<http://dl.dropbox.com/u/15024434/MessageBox.d>

I see you are calling Main.run twice, although you would only call it once it will work. But you'll also need to call Main.Quit twice, probably when the second 'Messagebox' is closed. This is because Main.run() runs the gtk eventloop and returns when Main.Quit is called. Yoe might also want to look at gtk.Dialog and gtk.MessageDialog for your "InputBox" and "MessageBox" respectively. gtk.Dialog has it's own run method which returns a response code when the user closes the dialog, by clicking ok/cancel/etc... or just closes it. -- Mike Wey

--000e0cd32c287b607204a80e5ec3 Content-Type: text/html; charset=ISO-8859-1 Thanks a lot for clarifying it for me. It runs perfectly now.<div>I should&#39;ve used gtk.(message)dialog but I got terribly lost in the gtk documentation and so I missed it.</div><div><br><div><br><div class="gmail_quote"> 2011/7/14 Mike Wey <span dir="ltr">&lt;<a href="mailto:mike-wey example.com">mike-wey example.com</a>&gt;</ pan><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"> On 07/14/2011 07:53 AM, maarten van damme wrote:<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"> when I leave destroy out the inputbox always stays visible even after<br> I&#39;ve pressed ok.<br> here are the other files<br> </div><a href="http://dl.dropbox.com/u/15024434/Main.d" target="_blank">http://dl.dropbox.com/u/<u></u>15024434/Main.d</a><div class="im"><br> <a href="http://dl.dropbox.com/u/15024434/InputBox.d" target="_blank">http://dl.dropbox.com/u/<u></u>15024434/InputBox.d</a><br> </div><a href="http://dl.dropbox.com/u/15024434/MessageBox.d" target="_blank">http://dl.dropbox.com/u/<u></u>15024434/MessageBox.d</a><br> </blockquote> <br> I see you are calling Main.run twice, although you would only call it once it will work. But you&#39;ll also need to call Main.Quit twice, probably when the second &#39;Messagebox&#39; is closed.<br> <br> This is because Main.run() runs the gtk eventloop and returns when Main.Quit is called.<br> <br> Yoe might also want to look at gtk.Dialog and gtk.MessageDialog for your &quot;InputBox&quot; and &quot;MessageBox&quot; respectively.<br> gtk.Dialog has it&#39;s own run method which returns a response code when the user closes the dialog, by clicking ok/cancel/etc... or just closes it.<br> <br> -- <br><font color="#888888"> Mike Wey<br> </font></blockquote></div><br></div></div> --000e0cd32c287b607204a80e5ec3--
Jul 14 2011