Changeset 9519 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 10/26/09 15:13:28 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MStatusArray.cc
r9039 r9519 72 72 // -------------------------------------------------------------------------- 73 73 // 74 // Remove objects matching the id (the first character of their class 75 // name) recuresively 76 // 77 void MStatusArray::RecursiveDelete(TVirtualPad *p, const char id) const 78 { 79 if (!p) 80 return; 81 82 TIter Next2(p->GetListOfPrimitives()); 83 TObject *o=0; 84 while ((o=Next2())) 85 { 86 if (!dynamic_cast<TVirtualPad*>(o) && (o->ClassName()[0]==id || id==0)) 87 delete p->GetListOfPrimitives()->Remove(o); 88 else 89 RecursiveDelete(dynamic_cast<TVirtualPad*>(o), id); 90 } 91 92 } 93 94 // -------------------------------------------------------------------------- 95 // 96 // Make sure to set the kMustCleanup for all object in our tree 97 // which will later be deleted when the array is destructed. 98 // 99 void MStatusArray::SetCleanup(TObject *obj) const 100 { 101 if (!obj) 102 return; 103 104 TVirtualPad *pad = dynamic_cast<TVirtualPad*>(obj); 105 106 // Do not set the bit for pads because it would end in 107 // endless recursions 108 if (pad && !dynamic_cast<TCanvas*>(obj)) 109 obj->ResetBit(kMustCleanup); 110 else 111 obj->SetBit(kMustCleanup); 112 113 if (!pad) 114 return; 115 116 TIter Next(pad->GetListOfPrimitives()); 117 TObject *o=0; 118 while ((o=Next())) 119 SetCleanup(o); 120 } 121 122 // -------------------------------------------------------------------------- 123 // 124 // Try to do a delete of the whole list in a way which is less vulnarable 125 // to double deletion due to wrongly set bits or other things 126 // 127 void MStatusArray::Delete(Option_t *) 128 { 129 // Add this to the list of cleanups to ensure as many cleaning 130 // operations as possible are propagated 131 gROOT->GetListOfCleanups()->Add(this); 132 133 // First make sure that all kMustCleanup bits are se 134 TIter Next(this); 135 TObject *o=0; 136 while ((o=Next())) 137 SetCleanup(o); 138 139 // Now delete the MARS object first because we have full control 140 // of them 141 TIter Next2(this); 142 while ((o=Next2())) 143 RecursiveDelete(dynamic_cast<TVirtualPad*>(o), 'M'); 144 145 // Now delete all root objects 146 TIter Next3(this); 147 while ((o=Next3())) 148 RecursiveDelete(dynamic_cast<TVirtualPad*>(o)); 149 150 // And delete all the rest 151 TObjArray::Delete(); 152 153 // Remove it from the list again 154 gROOT->GetListOfCleanups()->Remove(this); 155 } 156 157 // -------------------------------------------------------------------------- 158 // 74 159 // If o==NULL a new status display is created, otherwise the one with name o 75 160 // is searched in gROOT->GetListOfSpecials(). … … 335 420 } 336 421 422 MStatusArray::~MStatusArray() 423 { 424 // This is the destructor from TObjArray... 425 // It must be here, because for some reason I don't know it 426 // is otherwise not correctly executed from the Interpreter 427 // (root 5.12/00f) 428 if (IsOwner()) 429 Delete(); 430 431 TStorage::Dealloc(fCont); 432 433 fCont = 0; 434 fSize = 0; 435 } 436 337 437 // -------------------------------------------------------------------------- 338 438 // … … 344 444 // It seems that the contents are not properly deleted by TObjArray::Read 345 445 Delete(); 446 447 SetOwner(); 346 448 347 449 const TString keyname = name?name:"MStatusDisplay"; … … 372 474 TObject *o2=0; 373 475 while ((o2=Next2())) 374 if (o2->InheritsFrom( "MParContainer"))476 if (o2->InheritsFrom(MParContainer::Class())) 375 477 o2->SetBit(kCanDelete); 376 478 } -
trunk/MagicSoft/Mars/mbase/MStatusArray.h
r9490 r9519 19 19 }; 20 20 21 void SetCleanup(TObject *obj) const; 22 void RecursiveDelete(TVirtualPad *p, const char id=0) const; 23 21 24 void SetCanDelete(const TCollection *list) const; 22 25 void SetMyCanDelete(const TCollection *list) const; … … 28 31 MStatusArray() : TObjArray() { } 29 32 MStatusArray(const MStatusDisplay &d); 33 ~MStatusArray(); 30 34 31 35 TObject *DisplayIn(Option_t *o=0) const; // *MENU* … … 56 60 57 61 void EnableTH1Workaround(const TCollection *list=0) const; 62 void Delete(Option_t *option=""); 58 63 59 64 ClassDef(MStatusArray, 0) // Helper class for status display
Note:
See TracChangeset
for help on using the changeset viewer.