Changeset 5713
- Timestamp:
- 01/05/05 19:40:26 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r5701 r5713 23 23 2005/01/05 Thomas Bretz 24 24 25 * mbase/MStatusDisplay.cc:26 - fixed some lines in pulldown-menus27 - add TPads to ListOfCleanups in ClonePad (workaround!)28 29 25 * mcalib/MCalibrationBlindPix.cc, mcalib/MCalibrationChargeCalc.cc, 30 26 mhcalib/MHCalibrationRelTimeCam.cc: … … 41 37 - made sure that LoGain is flagged non-valid if no lo-gain exists 42 38 - push time back at the edge of the allowed limits if outside 39 40 * mbase/MGList.[h,cc]: 41 - introduced new functions Delete and DeletePictures 42 - SetBit(kMustCleanup) in constructor. Otherwise it is not 43 correctly removed from ListOfCleanups 44 45 * mbase/MLog.cc: 46 - SetBit(kMustCleanup) if adding a plugin to make sure it is cleaned 47 from the list 48 49 * mbase/MParContainer.[h,cc]: 50 - replaced return type of GetDescriptor by TString. The old version 51 was terribly wrong! The returned memory wasn't removed as soon 52 as the function returned. 53 54 * mbase/MStatusDisplay.[h,cc]: 55 - for security (thread safty) replaced all Form() by MString::Form() 56 - implemented a more secure scheme of Closing (Clone()) this was 57 a hint given by valgrind 58 - set kMustCleanup for all new object in ClonePad not only kCanDelete 59 - fixed some lines in pulldown-menus 60 - add TPads to ListOfCleanups in ClonePad (workaround!) 61 62 * mbase/MString.[h,cc]: 63 - implemented a new static Form() function returning a copy of 64 the result 65 66 * mbase/MTask.[h,cc]: 67 - replaced return type of GetDescriptor by TString. The old version 68 was terribly wrong! The returned memory wasn't removed as soon 69 as the function returned. 70 - Made GetDescriptor thread safe using MString::Form 71 72 * mfileio/MWriteRootFile.cc: 73 - Use GetDescriptor().Data() when using any kind of printf function 74 75 * mhbase/MFillH.cc: 76 - replaced string concatenation in all constructors by a Form 77 (also suggested by valgrind) 78 79 * mhcalib/MHCalibrationRelTimeCam.cc: 80 - made some output fit into 80col boundary 43 81 44 82 -
trunk/MagicSoft/Mars/mbase/MGList.cc
r4601 r5713 54 54 MGList::MGList() : TList() 55 55 { 56 // Make sure that all object deleted are also deleted from this list 56 57 gROOT->GetListOfCleanups()->Add(this); 58 // Make sure that this doesn't remain in ListOfCleanups after deletion 59 SetBit(kMustCleanup); 57 60 } 58 61 … … 63 66 // 64 67 MGList::~MGList() 68 { 69 DeletePictures(); 70 } 71 72 // -------------------------------------------------------------------------- 73 // 74 // Free/Delete all TGPicture store in list. 75 // 76 void MGList::DeletePictures() 65 77 { 66 78 TObject *obj; … … 82 94 // -------------------------------------------------------------------------- 83 95 // 96 // Delete all pictures. Call TList::Delete. 97 // 98 void MGList::Delete(Option_t *option) 99 { 100 DeletePictures(); 101 TList::Delete(option); 102 } 103 104 // -------------------------------------------------------------------------- 105 // 84 106 // Does a dynamic cast from a TObject to a TGWidget. This is necesary 85 107 // if a class derived from TObject inherits also from TGWidget and -
trunk/MagicSoft/Mars/mbase/MGList.h
r4601 r5713 16 16 17 17 void AddPicture(TGPicture *pic, const char *name); 18 void DeletePictures(); 18 19 19 20 public: … … 23 24 void Add(TObject *obj); 24 25 void Add(TObject *obj, Option_t *opt); 26 27 void Delete(Option_t *option=""); 25 28 26 29 const TGPicture *GetPicture(const char *name); -
trunk/MagicSoft/Mars/mbase/MLog.cc
r5692 r5713 117 117 118 118 #undef DEBUG 119 //#define DEBUG119 #define DEBUG 120 120 121 121 … … 701 701 // is automatically removed from the list of active plugins. 702 702 // 703 // If MLog should take the ownership cal plug->SetBit(kCanDelete);703 // If MLog should take the ownership call plug->SetBit(kCanDelete); 704 704 // 705 705 void MLog::AddPlugin(MLogPlugin *plug) 706 706 { 707 707 fPlugins->Add(plug); 708 } 708 709 // Make sure that it is recursively deleted from all objects in ListOfCleanups 710 plug->SetBit(kMustCleanup); 711 } -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r5692 r5713 208 208 // class name it returns the object name and in []-brackets the class name. 209 209 // 210 const char *MParContainer::GetDescriptor() const210 const TString MParContainer::GetDescriptor() const 211 211 { 212 212 return GetDescriptor(*this); … … 218 218 // class name it returns the object name and in []-brackets the class name. 219 219 // 220 const char *MParContainer::GetDescriptor(const TObject &o)220 const TString MParContainer::GetDescriptor(const TObject &o) 221 221 { 222 222 // … … 227 227 MString desc; 228 228 desc.Print("%s [%s]", o.GetName(), o.ClassName()); 229 return (TString)o.GetName()==o.ClassName() ? o.ClassName() : desc .Data();229 return (TString)o.GetName()==o.ClassName() ? o.ClassName() : desc; 230 230 } 231 231 -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r5557 r5713 74 74 virtual void FillBuffer(char *&buffer); 75 75 76 static const char *GetDescriptor(const TObject &o);76 static const TString GetDescriptor(const TObject &o); 77 77 78 virtual const char *GetDescriptor() const;78 virtual const TString GetDescriptor() const; 79 79 virtual const TString GetUniqueName() const; 80 80 virtual const char *GetName() const { return fName.Data(); } -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r5701 r5713 91 91 #include <TGProgressBar.h> // TGHProgressBar 92 92 #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas 93 94 #include "MString.h" 93 95 94 96 #include "MLog.h" // MLog … … 336 338 337 339 // Add MARS version 338 TGLabel *l = new TGLabel(f, Form("Official Release: V%s", MARSVER));340 TGLabel *l = new TGLabel(f, MString::Form("Official Release: V%s", MARSVER)); 339 341 fList->Add(l); 340 342 … … 347 349 348 350 // Add root version 349 l = new TGLabel(f, Form("Using ROOT v%s", ROOTVER));351 l = new TGLabel(f, MString::Form("Using ROOT v%s", ROOTVER)); 350 352 fList->Add(l); 351 353 … … 575 577 void MStatusDisplay::SetStatusLine2(const MParContainer &cont) 576 578 { 577 SetStatusLine2( Form("%s: %s", cont.GetDescriptor(), cont.GetTitle()));579 SetStatusLine2(MString::Form("%s: %s", cont.GetDescriptor().Data(), cont.GetTitle())); 578 580 } 579 581 … … 601 603 // from the list in the destructor. 602 604 // 603 gROOT->GetListOfSpecials()->Add(this);605 // gROOT->GetListOfSpecials()->Add(this); 604 606 605 607 fFont = gVirtualX->LoadQueryFont("7x13bold"); … … 694 696 695 697 // 696 // Delete the list listof canvases used in batch mode698 // Delete the list of canvases used in batch mode 697 699 // instead of the Root Embedded Canvases in the TGTab 698 700 // … … 971 973 { 972 974 // Tell the X-Requester how to call this method 973 TString str = Form("%d", (ULong_t)f);975 TString str = MString::Form("%d", (ULong_t)f); 974 976 975 977 TMethodCall call(IsA(), "UpdateTab", "NULL"); … … 1063 1065 gSystem->Unlink(name); 1064 1066 1065 SetStatusLine2( Form("Done (%dpage(s))", pages));1067 SetStatusLine2(MString::Form("Done (%dpage(s))", pages)); 1066 1068 1067 1069 return pages; … … 1177 1179 case kFileExit: 1178 1180 if (id==kFileExit || id==kFileClose) 1179 CloseWindow(); 1181 if (Close()) 1182 delete this; 1180 1183 fStatus = (Status_t)id; 1181 1184 return kTRUE; … … 1489 1492 } 1490 1493 1491 void MStatusDisplay::CloseWindow()1494 Bool_t MStatusDisplay::Close() 1492 1495 { 1493 1496 // Got close message for this MainFrame. Calls parent CloseWindow() … … 1512 1515 1513 1516 if (fIsLocked<=0 && IsOnHeap()) 1514 { 1515 //gLog << dbg << "delete " << fName << ";" << endl; 1516 delete this; 1517 // DO NOT EXECUTE ANY COMMAND AFTER this! 1518 } 1519 else 1520 { 1521 fStatus = kFileExit; 1522 //gLog << dbg << fName << ".fStatus=kFileExit;" << endl; 1523 } 1517 return kTRUE; 1518 1519 fStatus = kFileExit; 1520 return kFALSE; 1521 } 1522 1523 void MStatusDisplay::CloseWindow() 1524 { 1525 Close(); 1524 1526 } 1525 1527 … … 1621 1623 1622 1624 // Clone also important bits (FIXME: Is this correct) 1623 clone->SetBit(obj->TestBits(k MustCleanup|kCannotPick|kNoContextMenu));1625 clone->SetBit(obj->TestBits(kCannotPick|kNoContextMenu)); 1624 1626 1625 1627 // Now make sure that the clones are deleted at a later time 1626 clone->SetBit(kCanDelete );1628 clone->SetBit(kCanDelete|kMustCleanup); 1627 1629 1628 1630 // FIXME: This is a workaround for the problem with the MAstroCatalog in … … 2015 2017 } 2016 2018 2017 SetStatusLine2( Form("Tab #%d", i));2019 SetStatusLine2(MString::Form("Tab #%d", i)); 2018 2020 2019 2021 // … … 2078 2080 ps.TextNDC(0.5, 1.015, TString("MARS - Magic Analysis and Reconstruction Software - ")+d.AsString()); 2079 2081 ps.SetTextAlign(31); // right top 2080 ps.TextNDC(1, 1.015, Form("Page No.%i (%i) ", page++, i));2082 ps.TextNDC(1, 1.015, MString::Form("Page No.%i (%i) ", page++, i)); 2081 2083 line.PaintLineNDC(0, 1.01, 1, 1.01); 2082 2084 … … 2118 2120 *fLog << inf << "done." << endl; 2119 2121 2120 SetStatusLine2( Form("Done (%dpages)", page-1));2122 SetStatusLine2(MString::Form("Done (%dpages)", page-1)); 2121 2123 2122 2124 return page-1; … … 2165 2167 } 2166 2168 2167 SetStatusLine2( Form("Tab #%d", i));2169 SetStatusLine2(MString::Form("Tab #%d", i)); 2168 2170 2169 2171 // … … 2249 2251 } 2250 2252 2251 SetStatusLine2( Form("Tab #%d", i));2253 SetStatusLine2(MString::Form("Tab #%d", i)); 2252 2254 2253 2255 // … … 2460 2462 Bool_t MStatusDisplay::HandleEvent(Event_t *event) 2461 2463 { 2462 Bool_t rc = TGMainFrame::HandleEvent(event); 2464 // Instead of doing this in CloseWindow (called from HandleEvent) 2465 // we do it here. This makes sure, that handle event doesn't 2466 // execute code after deleting this. 2467 if (event->fType==kDestroyNotify) 2468 { 2469 if (Close()) 2470 delete this; 2471 // Close(); 2472 return kTRUE; 2473 } 2474 2475 const Bool_t rc = TGMainFrame::HandleEvent(event); 2463 2476 2464 2477 // -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r5620 r5713 110 110 Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2); 111 111 Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2); 112 Bool_t Close(); 112 113 void CloseWindow(); 113 114 Bool_t HandleConfigureNotify(Event_t *); -
trunk/MagicSoft/Mars/mbase/MString.cc
r4081 r5713 59 59 // string.Print(" MyString has %d bytes ", 128).Strip(TString::kBoth); 60 60 // 61 MString &MString::Print(const char *fmt, ...)61 MString &MString::Print(const char *fmt, va_list &ap) 62 62 { 63 va_list ap;64 va_start(ap, fmt);65 66 63 Int_t n=256; 67 64 … … 87 84 return *this; 88 85 } 86 87 // -------------------------------------------------------------------------- 88 // 89 // Thread safe replacement for Form, use it like: 90 // 91 // MString string; 92 // string.Print("MyString has %d bytes", 128); 93 // 94 // As a special feature the function returns the reference to the MString 95 // so that you can directly work with it, eg. 96 // 97 // string.Print(" MyString has %d bytes ", 128).Strip(TString::kBoth); 98 // 99 MString &MString::Print(const char *fmt, ...) 100 { 101 va_list ap; 102 va_start(ap, fmt); 103 104 return Print(fmt, ap); 105 } 106 107 // -------------------------------------------------------------------------- 108 // 109 // Thread safe replacement for Form, use it like: 110 // 111 // MString string; 112 // string.Print("MyString has %d bytes", 128); 113 // 114 // As a special feature the function returns the reference to the MString 115 // so that you can directly work with it, eg. 116 // 117 // string.Print(" MyString has %d bytes ", 128).Strip(TString::kBoth); 118 // 119 // The static version of this function returns a copy(!) of the resulting 120 // M/TString. 121 // 122 MString MString::Form(const char *fmt, ...) 123 { 124 va_list ap; 125 va_start(ap, fmt); 126 127 MString ret; 128 ret.Print(fmt, ap); 129 return ret; 130 } -
trunk/MagicSoft/Mars/mbase/MString.h
r4081 r5713 12 12 { 13 13 public: 14 MString &Print(const char *fmt, va_list &ap); 14 15 MString &Print(const char *fmt, ...); 16 static MString Form(const char *fmt, ...); 15 17 16 18 ClassDef(MString, 1) // Tool to make Form() thread safe against other TStrings -
trunk/MagicSoft/Mars/mbase/MTask.cc
r5351 r5713 101 101 #include <TStopwatch.h> // TStopwatch 102 102 103 #include "MString.h" 104 103 105 #include "MLog.h" 104 106 #include "MLogManip.h" … … 335 337 // name (eg. ;1) 336 338 // 337 const char *MTask::GetDescriptor() const339 const TString MTask::GetDescriptor() const 338 340 { 339 341 // … … 343 345 // 344 346 if (fName==ClassName()) 345 return fSerialNumber==0 ? ClassName() : Form("%s;%d", ClassName(), fSerialNumber);347 return fSerialNumber==0 ? ClassName() : MString::Form("%s;%d", ClassName(), fSerialNumber); 346 348 347 349 return fSerialNumber>0 ? 348 Form("%s;%d [%s]", fName.Data(), fSerialNumber, ClassName()) :349 Form("%s [%s]", fName.Data(), ClassName());350 MString::Form("%s;%d [%s]", fName.Data(), fSerialNumber, ClassName()) : 351 MString::Form("%s [%s]", fName.Data(), ClassName()); 350 352 } 351 353 -
trunk/MagicSoft/Mars/mbase/MTask.h
r5101 r5713 89 89 Byte_t GetSerialNumber() const { return fSerialNumber; } 90 90 91 const char *GetDescriptor() const;91 const TString GetDescriptor() const; 92 92 93 93 // Task execution statistics -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r5692 r5713 405 405 const char *cname = cont->GetName(); 406 406 const char *tname = entry->GetName(); 407 const TString ttitle(Form("Tree containing %s", cont->GetDescriptor() ));407 const TString ttitle(Form("Tree containing %s", cont->GetDescriptor().Data())); 408 408 409 409 // -
trunk/MagicSoft/Mars/mhbase/MFillH.cc
r4997 r5713 166 166 return; 167 167 168 fTitle = "Fill " + fHName;168 fTitle = Form("Fill %s", fHName.Data()); 169 169 if (fParContainerName.IsNull()) 170 170 return; 171 171 172 fTitle += " from " + fParContainerName;172 fTitle += Form(" from %s", fParContainerName.Data()); 173 173 } 174 174 … … 209 209 210 210 if (!title) 211 fTitle = "Fill " + fHName + " from " + par->GetDescriptor();211 fTitle = Form("Fill %s from %s", fName.Data(), par->GetDescriptor().Data()); 212 212 } 213 213 … … 236 236 return; 237 237 238 fTitle = (TString)"Fill " + hist->GetDescriptor();238 fTitle = Form("Fill %s", hist->GetDescriptor().Data()); 239 239 if (!par) 240 240 return; 241 241 242 fTitle += " from " + fParContainerName;242 fTitle += Form(" from %s", fParContainerName.Data()); 243 243 } 244 244 … … 265 265 266 266 if (!title) 267 fTitle = (TString)"Fill " + hist->GetDescriptor() + " from " + par->GetDescriptor();267 fTitle = Form("Fill %s from %s", hist->GetDescriptor().Data(), par->GetDescriptor().Data()); 268 268 } 269 269 -
trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc
r5685 r5713 679 679 if (overflow > 0.0005*hist->GetEntries()) 680 680 { 681 *fLog << warn << "HiGain Hist-overflow occurred" << overflow681 *fLog << warn << "HiGain Hist-overflow " << overflow 682 682 << " times in " << pix.GetName() << " (w/o saturation!) " << endl; 683 683 } … … 686 686 if (overflow > 0.0005*hist->GetEntries()) 687 687 { 688 *fLog << warn << "HiGain Hist-underflow occurred" << overflow688 *fLog << warn << "HiGain Hist-underflow " << overflow 689 689 << " times in " << pix.GetName() << " (w/o saturation!) " << endl; 690 690 }
Note:
See TracChangeset
for help on using the changeset viewer.