Can Q_GLOBAL_STATIC replace KStaticDelete ?

Matthias Kretz kretz at
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
^^ 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)                            <><
MatthiasKretz at, kretz at,
Matthias.Kretz at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the kde-core-devel mailing list