Review Request 121134: make KGlobal reference counting threadsafe

René J.V. Bertin rjvbertin at
Sun Nov 16 15:53:47 GMT 2014

This is an automatically generated e-mail. To reply, visit:

(Updated Nov. 16, 2014, 4:53 p.m.)

Review request for KDE Software on Mac OS X and kdelibs.

Repository: kdelibs


I have been experiencing unexpected exits from KDevelop that were not due to any kind of error in the KDevelop code; it was as if someone told the application to exit normally. This happens mostly on OS X, but also sometimes on Linux.
I finally traced this to `KGlobal::deref` reaching a zero reference count and invoking `QCoreApplication::quit` when called from one of KDevelop's KJob dtors. There does not appear to be a reference counting mismatch in the code, so the issue might be due to a race condition in KGlobal::ref/deref.

This patch introduces thread-safety to KGlobal's reference counting by turning the simple global `static int s_refCount` into a `static QAtomicInt s_refCount`. I consider this an important bug fix regardless of whether it corrects the issue I have with KDevelop.

Diffs (updated)

  kdecore/kernel/kglobal.cpp cf003a4 



On OS X 10.6.8 only for now.


René J.V. Bertin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the kde-core-devel mailing list