![]() |
|
#1
|
||||
|
||||
[FLTK] Proper way to close a window?I have done several smallish programs in FLTK and I like it quite a bit. I want to start refining my programs and making them more robust.
I have a concern with how I am handling the exit out of a sub-window. Currently, I have a call back set for a dialog window like: CPP / C++ / C Code:
However, when I call the function again, I have this (which recreates it): CPP / C++ / C Code:
So my concern is that every time I call this dialog, I am leaving it in memory when I exit. I can not for the life of me figure out how to properly close this though? Any suggestions? PS - I will be posting several FLTK questions here. If there is enough interest in this topic, I may be able to talk J into opening up a subforum... ![]() __________________
The best damn Sports Blog period. |
|
#2
|
||||
|
||||
|
Quote:
You're the Progamming Forums Chief, just send me the memo and it will be done. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
||||
|
||||
|
Quote:
I know that when you call hide on all windows - that means closing the application, the proper destructors are called and the memory is properly freed, as oppose to exit. However, I have no idea what happens when you call hide on a window while your program is still running .Stand by, I'm thinking Regards, Luci P.S:I am NOT a FLTK programmer (just seems a very simple Visual C __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#4
|
||||
|
||||
|
Quote:
I found a good response to my question. In retrospect, this is kind of a silly question, because the answer is kind of obvious. The hide() function simply does not display the window/dialog box/widget anymore, but the resources are still there. So if you want to create the resources only one time and use the same ones over and over, then just using the hide() and show() functions should not cause a problem. Unfortunately, the way that I have done my program, I create the resources each time I call the dialog box. (again - not the best way, but it does work). Therefore, when I "hide" my dialog box, I need to free these resources. In order to do this, I have changed my exit callback function to be: CPP / C++ / C Code:
__________________
The best damn Sports Blog period. |
|
#5
|
|||
|
|||
|
Quote:
Hello. If I have several windows opened, and I want to close the aplication, is it ok to just call exit(0)? what is the right way to do it? ed |
|
#6
|
||||
|
||||
|
Quote:
Technically, from what I understand. My opinion is, that if you can find your base application window and hide() it, then do that. That way, everything will be properly destroyed. FLTK takes care of widgets you create with new during it's lifespan so you don't need to handle those ones. That is the opinion that I have formed from reading the fltk newsgroups anyhow. I have been using : CPP / C++ / C Code:
You just need to be sure to setup your destructors to handle any delete (delete[]) 'ting that needs to be done on non-widget data. Once you hide the main window it's goodnite Irene for anything not handled. Quote:
Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
Recent GIDBlog
Halfway done! by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The