K_GLOBAL_STATIC and unittests?

Boudewijn Rempt boud at valdyas.org
Wed Nov 4 06:45:06 GMT 2009


On Wednesday 04 November 2009, David Faure wrote:
> 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...

Yes, that's what I seem to see: the various statics (and KOffice has too many 
of them) get destructed when running an app, but leak when running a test. 

-- 
Boudewijn Rempt | http://www.valdyas.org





More information about the kde-core-devel mailing list