Can Q_GLOBAL_STATIC replace KStaticDelete ?

Matthias Kretz kretz at kde.org
Thu Jan 18 10:54:09 GMT 2007


On Thursday 18 January 2007 00:42, Thiago Macieira wrote:
> I think that global statics that require Kinstance should be the absolute
> minority and code can be specially crafted for them.
>
> I think we should NOT have K_GLOBAL_STATIC. Adding it will complicate
> because the semantics won't be clear.

Just the first obvious item that showed up on lxr.kde.org:
http://lxr.kde.org/source/KDE/kdeaddons/konq-plugins/dirfilter/dirfilterplugin.cpp#053
^^ calls saveSettings in the dtor which uses KConfig

The problem is that as soon as you keep any KDE object as a member of a static 
object you have to be sure it's not going to need a KInstance object on 
destruction. Do you know whether you're allowed to keep a KDirWatch object? 
Would you have known that keeping a dirty KConfig object until destruction 
will crash your program on exit?

I think the semantics are clear with the following explanation (please add to 
it if you disagree):
The static object will be destructed by one of the following events (whichever 
comes first):
- lib unload/exit
- QCoreApplication destruction
- global KInstance destruction

The destruction order is the reverse of the construction order.

-- 
________________________________________________________
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: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070118/bad9d14e/attachment.sig>


More information about the kde-core-devel mailing list