Page 1 of 1

Delete Window object after removeChild method. [solved]

Posted: Wed Apr 08, 2009 22:11
by Toge
Hello.
I have a Window in other Window. If I remove the Window from the Window ( :roll: ), should I delete the removed window? must I delete the removed window?


Code: Select all

Window* win1 = ...

...

Window* win2 = new Window("TaharezLook/StaticText","win2");
win1->addChildWindow(win2);

...

win1->removeChildWindow("win2");
delete win;



Thanks.

Posted: Wed Apr 08, 2009 22:19
by CrazyEddie
Hi,

First you have to remember that CEGUI manages objects for you, this means that - with very few exceptions - you do not call 'new' or 'delete' for CEGUI objects directly, you create and destroy them via some 'manager' or factory object (so for a Window, that's the WindowManager).

To answer the specific question, it depends ;) If you're never going to want that window again, then go ahead and destroy it. If you're likely to want it again at some time, just 'orphan' it for now and reacquire it later via WindowManager::getWindow.

Any window objects still around when CEGUI is shut-down will automatically be destroyed.

HTH

CE