[ROOT] When to delete Root objects?

From: Aldo F. Saavedra (AFSaavedra@lbl.gov)
Date: Thu Oct 17 2002 - 23:32:16 MEST


Hi,

I have the following gap in my understanding of
the root framework.

I'm working on a application that uses ROOT classes
and QT.

I have a dialog class. When created, a TCanvas object
together with a few TGraph, TMultiGraph and TH2
objects are also created. So we have something like:

TCanvas *m_canvas;
TMultiGraph *m_AllGraphs;
TGraph *m_SillyGraph;
TH2 *m_CoolHisto;

and in the constructor

m_canvas = new TCanvas("ExtraCanvas","Floating",topx,topy,width,height);
m_AllGraphs = new TMultiGraph("All","");
m_SillyGraph = new TGraph(10);
m_CoolHisto = new TH2("Histo","Foo",50,minx,maxx,50,miny,maxy);

When I destroy the dialog object and I have not drawn anything on
the canvas everything is fine. The delete operator works well.
The problem arises when I draw some of the Root objects.

I read somewhere in the root website that when drawing on a canvas
the root objects get attached to a list. It seems that when I
destroy the canvas the objects on that list are also destroyed.
So the question is there a way to know if the root object
has already being deleted by a call to delete m_canvas.

I thought m_canvas->Clear() would release the root objects
from the list but does not seem to be the case.
What I'm trying to do is to release all the memory that was
allocated by the dialog.

Any help would be appreciated.



Cheers,
Aldo




***********************************************************
 Aldo F. Saavedra
 ATLAS Collaboration - Pixel Group (Physics Division)
 Lawrence Berkeley National Laboratory

 Email:          AFSaavedra@lbl.gov
 Phone:          1 510 486 4690
 Fax:		 1 510 486 5101
 Postal Address: Lawrence Berkeley National Laboratory
                 1 Cyclotron Rd Mailstop 50B-6208
                 Berkeley, CA 94720
                 USA



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