QApplication dtor change breaks KDE applications

Malte Starostik malte at kde.org
Tue Jul 8 02:26:54 BST 2003


Hi,

the addition of
is_app_closing = FALSE;
in QApplication::~QApplication() (qapplication.cpp:1093) causes invalid memory 
references during shutdown in some KDE applications, most notably konqueror. 
In my particular case the usual symptom is konqueror hanging around with 100% 
CPU usage in KDE's malloc replacement.
Here is what happens:
* QApplication is destroyed and sets is_app_closing to true in it's dtor
* later on, is_app_closing is reset to false (why?)
* control is passed to QObject::~QObject (QApplication's base dtor)
* child objects are destroyed, including KIO::Scheduler
* KIO::Scheduler destroys its slaves, which destroy a QSocketNotifier
* QSocketNotifier::~QSocketNotifier calls setEnabled( false ) which gets here:
    QEventLoop *eventloop = QApplication::eventLoop();
    if ( ! eventloop ) // perhaps application is shutting down
        return;

QApplication::eventLoop():
    if ( !eventloop && !is_app_closing )
        (void) new QEventLoop( qApp, "default event loop" );

But since QApplication's dtor reset is_app_closing before we arrived here, a 
new event loop is constructed instead of returning null. This results in an 
invalid reference to the already-closed X11 display when the event loop is 
initialized.

Thanks for fixing,
-Malte
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20030708/e2d20bd2/attachment.sig>


More information about the kde-core-devel mailing list