Can Q_GLOBAL_STATIC replace KStaticDelete ?

Ellis Whitehead ellis at kde.org
Mon Jan 8 20:06:22 GMT 2007


On 1/8/07, Thiago Macieira <thiago at kde.org> wrote:
> Matthias Kretz wrote:
> >> - KStaticDeleter delete objects in ~KApplication , while
> >> Q_GLOBAL_STATIC delete object after the end of main()
> >
> >This is a blocker for Q_GLOBAL_STATIC in many places of KDE. Many things
> > must be cleaned up before QCoreApplication is gone (just see my latest
> > commit to kdelibs/phonon).
>
> I saw the commit, but it doesn't explain why there is such a requirement.
>
> Why must those objects be deleted before QCoreApplication does away? Or
> why must they be deleted between QCoreApplication's destructor and the
> application's real exit?
>
> What happens to those objects if the application exits without
> QCoreApplication's destructor running?

I'm not sure how on-topic this is, but X and Qt leave a lot allocated
variables around when the program exits, and that makes "valgrind
--tool=memcheck" a royal pain.  For this reason, I'm strongly in favor
of calling static destructors, even if it means that program exit
takes an extra 10ms. :)

Best regards,
Ellis




More information about the kde-core-devel mailing list