digitalmars.D - Strange gtkd behaviour
- maarten van damme (27/27) Jul 13 2011 Hello everyone,
- Mike Wey (6/33) Jul 13 2011 I'm not sure if the Main.Quit gets executed after you've destroyed the
- maarten van damme (6/44) Jul 13 2011 when I leave destroy out the inputbox always stays visible even after I'...
- Mike Wey (12/18) Jul 14 2011 I see you are calling Main.run twice, although you would only call it
- maarten van damme (4/24) Jul 14 2011 Thanks a lot for clarifying it for me. It runs perfectly now.
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
Jul 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 :) MaartenI'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
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.dOn 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 :) MaartenI'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
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.dI 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
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
Jul 14 2011