How to get rid of a Desktop DocumentWind. on exit?

Hi all!

i (want to) create a extra desktop window like this:

[code]void Module::mouseDoubleClick ( const MouseEvent & e ) {

if (!moduleGUI) {
    moduleGUI =  new ModuleGUI(this->getName(),Colours::lightgrey,
                               DocumentWindow::allButtons,
                               true);
    moduleGUI->setBounds(0,0,200,200);
    moduleGUI->setVisible(true);
	//getTopLevelComponent()->addAndMakeVisible(moduleGUI);

} else {
	//moduleGUI->removeFromDesktop();
    deleteAndZero(moduleGUI);
	//moduleGUI = 0;
}

}[/code]

and this double click toggleing works nice.

but if i exit the whole app via “JUCE::quit()” and the window is open, i get a juce error while debugging telling me some window has not beeing deleted:

// doh! If you don't delete all your windows before exiting, you're going to // be leaking memory!

i added this to try to solve it
(since the window is not added to a parent , it seems necessary to get rid of it manually [children get deleted aututomaticle do they?] ):

Module::~Module() { if(moduleGUI )deleteAndZero( moduleGUI ); }

i also tried to use “removeFromDesktop();” in some places and combinations of both wich brings me to another warning/erro

but his gives me a hint to make this command thread save and use the “MessageManagerLock”, wich i use like this:
const MessageManagerLock mmLock;
wich then brings me back to the other error.

where to delete it?
pleas help me.

thanks.

D3CK

btw.: I really like the sytle of juce! you had java in mind? thanks for giving it to us.

Just delete it in the shutdown code of your JUCEApplication. Or make it inherit from DeletedAtShutdown to do it automatically. (Take a look at how the jucer and jucedemo handle this sort of thing). It’ll warn you about the messagemanager if you’re trying to delete it on another thread, which is a messy/inadvisable way to do it.

No!

Yes! And thx!

thanks jules. i wasn’t aware of the DeletedAtShutdown Class. i find giving pointers of all my children (and neverthele on the dektop) windows to the JUCEApplication class is a bit tedious. of course i tried to delete the children in the destructors with deleteAndZero, but this did not help (maybe i forgot a destructor, but there aren’t too much classes yet). so are there any disadvantages of just deriving form deleteAndZero? I have an idea how it works, so i think not. then i could derive almost everitign from it or is this bad?

thanks so far, i hope i can iron out my other rectangle ambigious problem too.

peace

D3CK