Hi Rene, Thanks for your reply. Adding the call B.SetDirectory(0) in A's constructor does not solve the problem. Originally, I had called B.SetDirectory(0) in A's custom Streamer function, which worked, but I would prefer to use the automatic Streamer. Also, calling the static TH1::AddDirectory(kFALSE) works around the problem, but I'd like to keep the ability to automatically add histograms to the current directory. --Mark Rene Brun wrote: > > Hi Mark, > > In the constructor of class A, you should add the following statement; > B.SetDirectory(0); > By definition, A owns B. However the TH1F constructor (by default) will > add the created histogram to the list of objects in the current directory/file. > When the file is closed, this object is deleted. You will get the object > deleted twice. > > You can also turn off the feature adding automatically the histogram objects > to the current directory (gDirectory->GetList()) by calling the static function > TH1::AddDirectory(kFALSE); > Note that if you do that, doing something like file->Write() will not > save your histograms to the file. > > Rene Brun > > Mark Boulay wrote: > > > > Hello, > > > > I have a class (call it class A), derived from TObject which has as a > > data member a TH1F > > (call it TH1F B). > > When an object of class A is read in from file, and then the file > > closed, > > a call is made to TObjectTable::Delete() deleting all objects which > > were > > contained in the file. > > The object A is first deleted, and then an attempt is made to delete B, > > since a reference to it still exists in gObjectTable. The problem > > is that B has presumably already been deleted along with A, since it > > is a data member of class A. > > > > I'm using ROOT 3.02.07 under RH linux 7.2. > > > > Thanks in advance for assistance, > > Mark
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET