Re: [ROOT] Destructors, stack objects.

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Mon Sep 23 2002 - 10:33:12 MEST


Hi Timur,

  just do:

   app->Run(kTRUE);

the true flag says to return from the event loop to the calling routine
on Terminate() instead of calling TSystem::Exit(). SetReturnFromRun() is
protected because it may only be called from TApplication::Run(). In the
default way when exit() is called the objects created in function from
which Run() is called are not deleted because exit() does not return to
to the calling method which objects never go out of scope. Global
objects are cleaned up by the run-time.

Cheers, Fons.


  
On Mon, 2002-09-23 at 09:53, Timur Pocheptsoff wrote:
> Hi.
> I have a programm with window and application object.
> I use my own house-breed global debug new/delete, and I have a problem.
> In my memleaks.log file there are some strings which show me, that destructors of local objects (created in function main), weren't called.	My window class has overriden virtual function CloseWindow in which I call gApplication->Terminate(0). What does Terminate do ? Using some tests, I've found out that it does something like standard exit(): only global, static objects, and static members are destructed (and objects from namespaces). Ok. There is a function SetReturnFromRun, (I can't understand, why it's protected), I create new class MyApp, derived from TApplication. In constructor SetReturnFromRun() called. But nothing changed :(((. Ok. I've overriden Terminate(), now I call gSystem->ExitLoop in it, and a result is worse: ***Break*** Segmentation violation.
> Please, help. 
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET