Can Q_GLOBAL_STATIC replace KStaticDelete ?

Matthias Kretz kretz at
Wed Jan 17 14:43:46 GMT 2007

On Wednesday 17 January 2007 12:51, Matthias Kretz wrote:
> I'm working on a K_GLOBAL_STATIC macro right now...

Patch is attached.

A few notes:
- I only took the threaded Q_GLOBAL_STATIC in account as KDE won't be compiled 
- I believe we need permission from Trolltech to use this, as it probably 
violates their copyright if we licence this as LGPL (dunno if the code in 
question is too small to be a problem, though).
- The destruction code is not thread safe and I believe it doesn't need to be 
(can it happen that ~QCoreApplication and ~KInstance are running in two 
separate threads, or that the static object cleanup happens in more than one 
thread at the same time - or any other combination?)
- Using K_GLOBAL_STATIC for a singleton requires the ctor and dtor of the 
singleton-class to be public. Is there a way to make the static function 
declared by K_GLOBAL_STATIC a friend of the class?

Matthias Kretz (Germany)                            <><
MatthiasKretz at, kretz at,
Matthias.Kretz at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kglobalstatic.diff
Type: text/x-diff
Size: 9356 bytes
Desc: not available
URL: <>
-------------- 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