Thread overview
Strange gtkd behaviour
Jul 13, 2011
maarten van damme
Jul 13, 2011
Mike Wey
Jul 14, 2011
maarten van damme
Jul 14, 2011
Mike Wey
Jul 14, 2011
maarten van damme
July 13, 2011
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


July 13, 2011
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
July 14, 2011
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
>


July 14, 2011
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
July 14, 2011
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
>