- Timestamp:
- 12/23/09 11:45:35 (15 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9531 r9532 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2009/12/23 Thomas Bretz 22 23 * mbase/MStatusArray.[h,cc]: 24 - implemented a special treatment for TGraphs in RecursiveRemove 25 to make sure that the fHistogram pointer doesn't get deleted 26 twice. 27 - implemented a small fix to make sure an object which is more than 28 once in a list of primitives gets really removed. 29 30 20 31 21 32 2009/12/21 Thomas Bretz -
trunk/MagicSoft/Mars/mbase/MStatusArray.cc
r9519 r9532 18 18 ! Author(s): Thomas Bretz 03/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2009 21 21 ! 22 22 ! … … 57 57 ClassImp(MStatusArray); 58 58 59 #include <TGraph.h> 60 59 61 using namespace std; 60 62 … … 85 87 { 86 88 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); 89 { 90 while (p->GetListOfPrimitives()->Remove(o)); 91 delete o; 92 93 continue; 94 } 95 96 RecursiveDelete(dynamic_cast<TVirtualPad*>(o), id); 90 97 } 91 98 … … 122 129 // -------------------------------------------------------------------------- 123 130 // 131 // This is a workaround to make sure that TH1 which are part of two TGraphs 132 // (TGraph::GetHistogram) are not finally deleted twice. Unfortunately, 133 // TGraph doesn't have it in RecursiveRemove. 134 // 135 void MStatusArray::RecursiveRemove(TVirtualPad *p, TObject *obj) 136 { 137 if (!p) 138 return; 139 140 TIter Next(p->GetListOfPrimitives()); 141 TObject *o=0; 142 while ((o=Next())) 143 { 144 if (dynamic_cast<TGraph*>(o)) 145 { 146 TGraph *g = static_cast<TGraph*>(o); 147 if (g->GetHistogram()==obj) 148 g->SetHistogram(0); 149 150 continue; 151 } 152 153 RecursiveRemove(dynamic_cast<TVirtualPad*>(o), obj); 154 } 155 156 } 157 158 // -------------------------------------------------------------------------- 159 // 160 // This is a workaround to make sure that TH1 which are part of two TGraphs 161 // (TGraph::GetHistogram) are not finally deleted twice. Unfortunately, 162 // TGraph doesn't have it in RecursiveRemove. 163 // 164 void MStatusArray::RecursiveRemove(TObject *obj) 165 { 166 TObjArray::RecursiveRemove(obj); 167 168 TObject *o = 0; 169 170 TIter Next(this); 171 while ((o=Next())) 172 RecursiveRemove(dynamic_cast<TVirtualPad*>(o), obj); 173 } 174 175 // -------------------------------------------------------------------------- 176 // 124 177 // Try to do a delete of the whole list in a way which is less vulnarable 125 178 // to double deletion due to wrongly set bits or other things -
trunk/MagicSoft/Mars/mbase/MStatusArray.h
r9519 r9532 62 62 void Delete(Option_t *option=""); 63 63 64 void RecursiveRemove(TVirtualPad *p, TObject *o); 65 void RecursiveRemove(TObject *o); 66 64 67 ClassDef(MStatusArray, 0) // Helper class for status display 65 68 };
Note:
See TracChangeset
for help on using the changeset viewer.