K_GLOBAL_STATIC and unittests?

David Faure faure at kde.org
Wed Nov 4 00:48:39 GMT 2009


On Saturday 17 October 2009, Boudewijn Rempt wrote:
> On Saturday 17 October 2009, Thiago Macieira wrote:
> > Em Sábado 17. Outubro 2009, às 09.49.54, Boudewijn Rempt escreveu:
> > > It seems that statics created with K_GLOBAL_STATIC aren't destroyed
> > > when they are created in a unittest, though it works perfectly in a
> > > real application. Is that something known or intentional?
> >
> > Global statics are destroyed when the application exits. That's too late
> >  for the tests.
> 
> Ah, I thought something defined by, say,
> QTEST_KDEMAIN(KisPaintDeviceActionTest, GUI) was an application, so I
>  expected K_GLOBAL_STATIC to be destroyed on shutdown.

Yes, on shutdown, i.e. after main() returns.
But that means you can't test it from any of your tests, that's what Thiago 
meant.

But if you don't see the thing being deleted at all, i.e. if you see a memory 
leak, then that's very very surprising. It certainly works in the kdelibs 
unittests, AFAIK...

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).




More information about the kde-core-devel mailing list