K_GLOBAL_STATIC and unittests?

David Faure faure at kde.org
Thu Nov 5 12:49:27 GMT 2009


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

And what about the statics from kdelibs? Are they destroyed or leaked, in your 
unit tests? (and when you run the kdelibs unittests)?
Can you try to reduce the problem to the smallest testcase that shows the 
issue?

-- 
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