[PATCH] KApplication's refcounting woes
Martijn Klingens
klingens at kde.org
Sun Oct 5 13:13:22 BST 2003
While trying to make Kopete's plugin unloading on exit async I wanted to add
an extra ref() to the KApplication object to make sure the plugin manager
outlives the main window. This works, and when my handler is called it
successfully derefs the app.
However, after I deref the app it's still using a refcount of 1 instead of 0
and doesn't terminate.
kapplication.cpp contains a comment:
----
/**
* This counter indicates when to exit the application.
* It starts at 1, is decremented by the "last window close" event, but
* is incremented by operations that should outlive the last window closed
* (e.g. a file copy for a file manager, or 'compacting folders on exit' for
* a mail client).
*/
int refCount;
----
Although the comment says so KApplication does _NOT_ deref on
latWindowClosed(). Attached oneliner does so in the case of guiEnabled, but I
have no idea how to fix it for non-GUI applications.
Worse, I'm afraid changes like this add tons of side effects (though it seems
to work for me (TM) :), so could someone please review this first?
--
Martijn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kapplication.diff
Type: text/x-diff
Size: 755 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20031005/121dca20/attachment.diff>
More information about the kde-core-devel
mailing list