Dear Rooters I have a strange problem in a pretty complex program, where I store TTrees in a TFile in one root session, but am also able to add, delete or update trees in the next session. The important classes compiled as library are: class TContent: public TList {} class TBaseClass: public TNamed { void AddTree(); void UpdateTree(); void DeleteTree(); } class DerivedClass: public TBaseClass {} class MyClass: public TNamed { TFile *fFile; TContent *fContent; void AddData() {derivedClass->AddTree();} void UpdateData() {derivedClass->UpdateTree();} void DeleteData() {derivedClass->DeleteTree();} } First root session: In a macro I call myClass->AddData(tree1). A tree is created in fFile, and derivedClass1 is stored in fContent. Assume that I have created three trees in this way, tree1, tree2 and tree3. When I call TBrowser, everything is perfectly ok. Second root session: In a macro I call: myClass->AddData(tree4) myClass->DeleteData(tree1) myClass->DeleteData(tree2) myClass->AddData(tree5) When I open fFile with TBrowser, tree4 and tree5 are added, and their corresponding derivedClass4 and derivedClass5 is added to fContent, while tree1 and tree2 are deleted and their corresponding derivedClass1 and derivedClass2 are deleted from fContent, as expected. So far everything is ok. But now fFile contains suddenly the three derivedClass1,2,3 from the first root session as single objects in fFile. Apparently, the old content of fContent is read and stored in fFile. I do not understand, why these objects are suddenly stored in fFile, since I never call fFile->Write() but only obj->Write(). The destructor of BaseClass looks as follows: BaseClass::~BaseClass { if (fFile) { // Write content to file only if new file or file is updated fFile->cd(); if (fContent && (strcmp(fFile->GetOption(), "READ") != 0)) { // kSingleKey since fContent is a TCollection!! fContent->Write("", TObject::kSingleKey | TObject::kOverwrite); }//if fContent->Delete(); SafeDelete(fContent); SafeDelete(fFile); }//if // fTrash->Delete(); SafeDelete(fTrash); } My questions are: Can anybody give me a hint why the objects are written to fFile? How can I prevent that the old list content is written to fFile? Thank you in advance for your help. Best regards Christian _._._._._._._._._._._._._._._._ C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a A.u.s.t.r.i.a _._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:04 MET