Changeset 8299 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 02/03/07 20:16:15 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MStatusArray.cc
r8284 r8299 237 237 if (lvl>0) 238 238 gLog << setw(lvl) << ' '; 239 gLog << o->ClassName() << ": " << o->GetName() << " <" << Next.GetOption() << "> (" << o << ")"<< endl;239 gLog << " " << o->ClassName() << ": " << o->GetName() << " <" << Next.GetOption() << "> (" << o << ") " << (int)o->TestBit(kCanDelete) << endl; 240 240 } 241 241 … … 245 245 } 246 246 247 // -------------------------------------------------------------------------- 248 // 249 // Print recursively all objects in this and sub-pads. If !option.IsNull() 250 // only objects in the corresponding pad are printed. 251 // 252 void MStatusArray::Print(Option_t *option) const 253 { 254 const TString opt(option); 255 256 PrintObjectsInPad(this, opt); 257 } 258 259 /* 247 260 // -------------------------------------------------------------------------- 248 261 // … … 261 274 else 262 275 o->SetBit(kCanDelete|kMustCleanup); 276 } 277 } 278 */ 279 280 // -------------------------------------------------------------------------- 281 // 282 // Set kCanDelete for all objects for which kMyCanDelete is set. This 283 // is a STUPID workaruond for an ANNOYING root bug which is that 284 // the streamer function of TH1 resets the KCanDelete bit after reading. 285 // 286 void MStatusArray::SetCanDelete(const TCollection *list) const 287 { 288 TIter Next(list); 289 TObject *o=0; 290 while ((o=Next())) 291 { 292 if (o->InheritsFrom(TVirtualPad::Class())) 293 SetCanDelete(((TVirtualPad*)o)->GetListOfPrimitives()); 294 else 295 { 296 if (o->TestBit(kMyCanDelete) && o->InheritsFrom("TH1")) 297 { 298 o->SetBit(kCanDelete); 299 o->ResetBit(kMyCanDelete); 300 } 301 } 302 } 303 } 304 305 void MStatusArray::EnableTH1Workaround(const TCollection *list) const 306 { 307 TIter Next(list?list:this); 308 TObject *o=0; 309 while ((o=Next())) 310 { 311 if (o->InheritsFrom(TVirtualPad::Class())) 312 EnableTH1Workaround(((TVirtualPad*)o)->GetListOfPrimitives()); 313 else 314 if (o->InheritsFrom("TH1")) 315 o->SetBit(kCanDelete); 316 } 317 } 318 319 // -------------------------------------------------------------------------- 320 // 321 // Set kMyCanDelete for all objects for which kCanDelete is set. This 322 // is a STUPID workaruond for an ANNOYING root bug which is that 323 // the streamer function of TH1 resets the KCanDelete bit after reading. 324 // 325 void MStatusArray::SetMyCanDelete(const TCollection *list) const 326 { 327 TIter Next(list); 328 TObject *o=0; 329 while ((o=Next())) 330 { 331 if (o->InheritsFrom(TVirtualPad::Class())) 332 SetMyCanDelete(((TVirtualPad*)o)->GetListOfPrimitives()); 333 else 334 { 335 if (o->TestBit(kMyCanDelete) && o->InheritsFrom("TH1")) 336 gLog << warn << "WARNING - MStatusArray::Write - " << o->GetName() << " [" << o->ClassName() << "] has BIT(30) already set!" << endl; 337 338 if (o->TestBit(kCanDelete) && o->InheritsFrom("TH1")) 339 o->SetBit(kMyCanDelete); 340 } 341 } 342 } 343 344 // -------------------------------------------------------------------------- 345 // 346 // Reset kMyCanDelete for all objects for which kMyCanDelete is set. This 347 // is a STUPID workaruond for an ANNOYING root bug which is that 348 // the streamer function of TH1 resets the KCanDelete bit after reading. 349 // 350 void MStatusArray::ResetMyCanDelete(const TCollection *list) const 351 { 352 TIter Next(list); 353 TObject *o=0; 354 while ((o=Next())) 355 { 356 if (o->InheritsFrom(TVirtualPad::Class())) 357 ResetMyCanDelete(((TVirtualPad*)o)->GetListOfPrimitives()); 358 else 359 { 360 if (o->TestBit(kMyCanDelete) && o->InheritsFrom("TH1")) 361 o->ResetBit(kMyCanDelete); 362 } 263 363 } 264 364 } … … 280 380 TH1::AddDirectory(store); 281 381 382 // All objects in the list (TNamed, TCanvas, etc) do not have 383 // the kCanDelete bit set. Make sure that it is set to make 384 // them deleted by the destructor of this list 385 TIter Next(this); 386 TObject *o=0; 387 while ((o=Next())) 388 { 389 if (o->InheritsFrom(TVirtualPad::Class())) 390 { 391 TIter Next2(((TVirtualPad*)o)->GetListOfPrimitives()); 392 TObject *o2=0; 393 while ((o2=Next2())) 394 if (o2->InheritsFrom("MParContainer")) 395 o2->SetBit(kCanDelete); 396 } 397 o->SetBit(kCanDelete); 398 } 399 282 400 // Make sure that all kCanDelete bits are properly set 283 401 SetCanDelete(this); … … 289 407 // -------------------------------------------------------------------------- 290 408 // 291 // Print recursively all objects in this and sub-pads. If !option.IsNull() 292 // only objects in the corresponding pad are printed. 293 // 294 void MStatusArray::Print(Option_t *option) const 295 { 296 const TString opt(option); 297 298 PrintObjectsInPad(this, opt); 299 } 409 // Switch off adding histograms to current directory before reading. 410 // Switch back 411 // 412 Int_t MStatusArray::Write(const char *name, Int_t option, Int_t bufsize) const 413 { 414 SetMyCanDelete(this); 415 const Int_t rc = TObjArray::Write(name, option, bufsize); 416 ResetMyCanDelete(this); 417 418 return rc; 419 } -
trunk/MagicSoft/Mars/mbase/MStatusArray.h
r8284 r8299 15 15 { 16 16 private: 17 enum { 18 kMyCanDelete = BIT(30) 19 }; 20 17 21 void SetCanDelete(const TCollection *list) const; 22 void SetMyCanDelete(const TCollection *list) const; 23 void ResetMyCanDelete(const TCollection *list) const; 18 24 void PrintObjectsInPad(const TCollection *list, const TString &name, Int_t lvl=0) const; 19 25 TObject *FindObjectInPad(TVirtualPad *pad, const char *object, TClass *base) const; … … 43 49 44 50 Int_t Read(const char *name=NULL); 51 Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0) const; 52 Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0) 53 { 54 return const_cast<const MStatusArray*>(this)->Write(name, option, bufsize); 55 } 56 57 void EnableTH1Workaround(const TCollection *list=0) const; 45 58 46 59 ClassDef(MStatusArray, 0) // Helper class for status display
Note:
See TracChangeset
for help on using the changeset viewer.