[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: deleting main windows
From: Lubos Lunak <l.lunak () sh ! cvut ! cz>
Date: 2002-07-06 20:05:30
[Download RAW message or body]
Hello,
I've run into a small problem with QMainWindow derived classes and I'm not
sure who to blame. Simply said, they are not deleled if they're not closed.
If you simply call qApp->quit(), none of currently existing main windows
destructors will be called. The destructors will be only called if the window
is explicitly closed (because of WDestructiveClose).
Since we even have a RESTORE macro for KMainWindow, which dynamically
allocates the instance and forgets the pointer immediately, we're most
probably missing cleanup actions in all applications. In some cases it
apparently doesn't matter, but in mine it does.
In kdebase/konqueror/konq_main.cc, there's at the end of main() this piece of
code :
//// Temporary code, waiting for Qt to do this properly
// Delete all toplevel widgets that have WDestructiveClose, so that we don't
have
// any parts loaded when KLibLoader::cleanUp is called.
QWidgetList *list = QApplication::topLevelWidgets();
QWidgetListIt it(*list);
QWidget * w;
while( (w=it.current()) != 0 ) {
++it;
if ( w->testWFlags( Qt::WDestructiveClose ) )
delete w;
}
(Especially the first comment is interesting - it's there since Dec 2000 :-/.
And depending on where the proper solution belongs, this piece of code may
still be needed for proper cleanup order.)
Ok, so what should be the correct solution? Should all WDestructiveClose
window be deleted in let's say QApplication destructor? Should the app be
responsible for deleting all its toplevel widgets (ugh)? Should all
Q(K)MainWindow class register all its instances and delete them? New widget
flag WDestroyAtAppExit?
--
Lubos Lunak
l.lunak@email.cz ; l.lunak@kde.org
http://dforce.sh.cvut.cz/~seli
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic