Can Q_GLOBAL_STATIC replace KStaticDelete ?
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:
^^ 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
- lib unload/exit
- QCoreApplication destruction
- global KInstance destruction
The destruction order is the reverse of the construction order.
Matthias Kretz (Germany) <><
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
Size: 189 bytes
Desc: not available
More information about the kde-core-devel