Can Q_GLOBAL_STATIC replace KStaticDelete ?
Matthias Kretz
kretz at kde.org
Mon Jan 22 20:46:54 GMT 2007
On Friday 19 January 2007 13:19, Thiago Macieira wrote:
> Matthias Kretz wrote:
> > Now it will abort with a helpful
> > error message if you access the global static after destruction (this
> > would have spared me one day of debugging if Q_GLOBAL_STATIC had
> > aborted instead of returning 0).
> > e.g.: accessed global static 'A *getA()' after destruction
>
> Good idea.
After trying it with some classes that were using KStaticDeleter before I
think we must support the case where the global static is already deleted
while some code might still access it if it's there.
Concrete example:
KSharedConfig keeps a global QList of all KSharedConfig objects. At some point
this list will be deleted but there might still be KSharedConfig objects
stored somewhere (new ones should not be created and should lead to an
error). But in the dtor of KSharedConfig the object is taken out of the
global list. Now a simple check is missing to make it not abort. See attached
patch which adds another method "bool NAME##_isDestroyed()".
--
________________________________________________________
Matthias Kretz (Germany) <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kglobal.h.diff
Type: text/x-diff
Size: 3045 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070122/5f1e08b6/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070122/5f1e08b6/attachment.sig>
More information about the kde-core-devel
mailing list