Can Q_GLOBAL_STATIC replace KStaticDelete ?

Olivier Goffart ogoffart at
Mon Jan 8 15:50:01 GMT 2007

KStaticDeleter / Q_GLOBAL_STATIC

Previous thread make me ask if we still need KStaticDeleter

So can Q_GLOBAL_STATIC replace KStaticDeleter ?

+ Q_GLOBAL_STATIC is thread safe while KStaticDeleter is not  (but could 
eventually be modified)

- Q_GLOBAL_STATIC is not documented by Qt (at least i did not find the 
documentation),  is it a part on the public API ?

+ Q_GLOBAL_STATIC require a bit less code :-)

- KStaticDeleter support arrays, Q_GLOBAL_STATIC don't

- KStaticDeleter delete objects in  ~KApplication ,  while Q_GLOBAL_STATIC 
delete object after the end of main()
If there is no KApplication, object are destroyed in the same time for both 
Q_GLOBAL_STATIC and KStaticDeleter.

Should KStaticDeleter be fixed to be thread safe ?
Or Should we remove KStaticDeleter in favor of Q_GLOBAL_STATIC ?

Is there any place where the static object is required to be destroyed before 
KApplication ?
If this is the case, and the singletton is a QObject, it can use KApplication 
as parent object ?
If this is not a QObject, there still are workaround using qAddPostRoutine,  
but if we need to add too much workaround better to keep KStaticDeleter.

Is there a case when we have a static pointer to an array of object ? 
And if this is the case, i think we could use a static QVector
According to my grepping, only KCmdLineArgs allocate a static dynamic array of 
char, maybe QByteArray could be used instead.

So what is your opinion ?
-------------- 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