Changeset 5713 for trunk


Ignore:
Timestamp:
01/05/05 19:40:26 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5701 r5713  
    2323 2005/01/05 Thomas Bretz
    2424
    25    * mbase/MStatusDisplay.cc:
    26      - fixed some lines in pulldown-menus
    27      - add TPads to ListOfCleanups in ClonePad (workaround!)
    28 
    2925   * mcalib/MCalibrationBlindPix.cc, mcalib/MCalibrationChargeCalc.cc,
    3026     mhcalib/MHCalibrationRelTimeCam.cc:
     
    4137     - made sure that LoGain is flagged non-valid if no lo-gain exists
    4238     - 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
    4381
    4482
  • trunk/MagicSoft/Mars/mbase/MGList.cc

    r4601 r5713  
    5454MGList::MGList() : TList()
    5555{
     56    // Make sure that all object deleted are also deleted from this list
    5657    gROOT->GetListOfCleanups()->Add(this);
     58    // Make sure that this doesn't remain in ListOfCleanups after deletion
     59    SetBit(kMustCleanup);
    5760}
    5861
     
    6366//
    6467MGList::~MGList()
     68{
     69    DeletePictures();
     70}
     71
     72// --------------------------------------------------------------------------
     73//
     74//  Free/Delete all TGPicture store in list.
     75//
     76void MGList::DeletePictures()
    6577{
    6678    TObject *obj;
     
    8294// --------------------------------------------------------------------------
    8395//
     96//  Delete all pictures. Call TList::Delete.
     97//
     98void MGList::Delete(Option_t *option)
     99{
     100    DeletePictures();
     101    TList::Delete(option);
     102}
     103
     104// --------------------------------------------------------------------------
     105//
    84106//  Does a dynamic cast from a TObject to a TGWidget. This is necesary
    85107//  if a class derived from TObject inherits also from TGWidget and
  • trunk/MagicSoft/Mars/mbase/MGList.h

    r4601 r5713  
    1616
    1717    void      AddPicture(TGPicture *pic, const char *name);
     18    void      DeletePictures();
    1819
    1920public:
     
    2324    void Add(TObject *obj);
    2425    void Add(TObject *obj, Option_t *opt);
     26
     27    void Delete(Option_t *option="");
    2528
    2629    const TGPicture *GetPicture(const char *name);
  • trunk/MagicSoft/Mars/mbase/MLog.cc

    r5692 r5713  
    117117
    118118#undef DEBUG
    119 //#define DEBUG
     119#define DEBUG
    120120
    121121
     
    701701// is automatically removed from the list of active plugins.
    702702//
    703 // If MLog should take the ownership cal plug->SetBit(kCanDelete);
     703// If MLog should take the ownership call plug->SetBit(kCanDelete);
    704704//
    705705void MLog::AddPlugin(MLogPlugin *plug)
    706706{
    707707    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  
    208208// class name it returns the object name and in []-brackets the class name.
    209209//
    210 const char *MParContainer::GetDescriptor() const
     210const TString MParContainer::GetDescriptor() const
    211211{
    212212    return GetDescriptor(*this);
     
    218218// class name it returns the object name and in []-brackets the class name.
    219219//
    220 const char *MParContainer::GetDescriptor(const TObject &o)
     220const TString MParContainer::GetDescriptor(const TObject &o)
    221221{
    222222    //
     
    227227    MString desc;
    228228    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;
    230230}
    231231
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r5557 r5713  
    7474    virtual void        FillBuffer(char *&buffer);
    7575
    76     static const char *GetDescriptor(const TObject &o);
     76    static const TString GetDescriptor(const TObject &o);
    7777
    78     virtual const char   *GetDescriptor() const;
     78    virtual const TString GetDescriptor() const;
    7979    virtual const TString GetUniqueName() const;
    8080    virtual const char   *GetName() const       { return fName.Data(); }
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r5701 r5713  
    9191#include <TGProgressBar.h>        // TGHProgressBar
    9292#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
     93
     94#include "MString.h"
    9395
    9496#include "MLog.h"                 // MLog
     
    336338
    337339    // 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));
    339341    fList->Add(l);
    340342
     
    347349
    348350    // 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));
    350352    fList->Add(l);
    351353
     
    575577void MStatusDisplay::SetStatusLine2(const MParContainer &cont)
    576578{
    577     SetStatusLine2(Form("%s: %s", cont.GetDescriptor(), cont.GetTitle()));
     579    SetStatusLine2(MString::Form("%s: %s", cont.GetDescriptor().Data(), cont.GetTitle()));
    578580}
    579581
     
    601603    // from the list in the destructor.
    602604    //
    603     gROOT->GetListOfSpecials()->Add(this);
     605//    gROOT->GetListOfSpecials()->Add(this);
    604606
    605607    fFont = gVirtualX->LoadQueryFont("7x13bold");
     
    694696
    695697    //
    696     // Delete the list list of canvases used in batch mode
     698    // Delete the list of canvases used in batch mode
    697699    // instead of the Root Embedded Canvases in the TGTab
    698700    //
     
    971973    {
    972974        // 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);
    974976
    975977        TMethodCall call(IsA(), "UpdateTab", "NULL");
     
    10631065    gSystem->Unlink(name);
    10641066
    1065     SetStatusLine2(Form("Done (%dpage(s))", pages));
     1067    SetStatusLine2(MString::Form("Done (%dpage(s))", pages));
    10661068
    10671069    return pages;
     
    11771179    case kFileExit:
    11781180        if (id==kFileExit || id==kFileClose)
    1179             CloseWindow();
     1181            if (Close())
     1182                delete this;
    11801183        fStatus = (Status_t)id;
    11811184        return kTRUE;
     
    14891492}
    14901493
    1491 void MStatusDisplay::CloseWindow()
     1494Bool_t MStatusDisplay::Close()
    14921495{
    14931496    // Got close message for this MainFrame. Calls parent CloseWindow()
     
    15121515
    15131516    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
     1523void MStatusDisplay::CloseWindow()
     1524{
     1525    Close();
    15241526}
    15251527
     
    16211623
    16221624        // Clone also important bits (FIXME: Is this correct)
    1623         clone->SetBit(obj->TestBits(kMustCleanup|kCannotPick|kNoContextMenu));
     1625        clone->SetBit(obj->TestBits(kCannotPick|kNoContextMenu));
    16241626
    16251627        // Now make sure that the clones are deleted at a later time
    1626         clone->SetBit(kCanDelete);
     1628        clone->SetBit(kCanDelete|kMustCleanup);
    16271629
    16281630        // FIXME: This is a workaround for the problem with the MAstroCatalog in
     
    20152017        }
    20162018
    2017         SetStatusLine2(Form("Tab #%d", i));
     2019        SetStatusLine2(MString::Form("Tab #%d", i));
    20182020
    20192021        //
     
    20782080        ps.TextNDC(0.5, 1.015, TString("MARS - Magic Analysis and Reconstruction Software - ")+d.AsString());
    20792081        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));
    20812083        line.PaintLineNDC(0, 1.01, 1, 1.01);
    20822084
     
    21182120        *fLog << inf << "done." << endl;
    21192121
    2120     SetStatusLine2(Form("Done (%dpages)", page-1));
     2122    SetStatusLine2(MString::Form("Done (%dpages)", page-1));
    21212123
    21222124    return page-1;
     
    21652167        }
    21662168
    2167         SetStatusLine2(Form("Tab #%d", i));
     2169        SetStatusLine2(MString::Form("Tab #%d", i));
    21682170
    21692171        //
     
    22492251        }
    22502252
    2251         SetStatusLine2(Form("Tab #%d", i));
     2253        SetStatusLine2(MString::Form("Tab #%d", i));
    22522254
    22532255        //
     
    24602462Bool_t MStatusDisplay::HandleEvent(Event_t *event)
    24612463{
    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);
    24632476
    24642477    //
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r5620 r5713  
    110110    Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2);
    111111    Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2);
     112    Bool_t Close();
    112113    void   CloseWindow();
    113114    Bool_t HandleConfigureNotify(Event_t *);
  • trunk/MagicSoft/Mars/mbase/MString.cc

    r4081 r5713  
    5959//  string.Print("  MyString has %d bytes  ", 128).Strip(TString::kBoth);
    6060//
    61 MString &MString::Print(const char *fmt, ...)
     61MString &MString::Print(const char *fmt, va_list &ap)
    6262{
    63     va_list ap;
    64     va_start(ap, fmt);
    65 
    6663    Int_t n=256;
    6764
     
    8784    return *this;
    8885}
     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//
     99MString &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//
     122MString 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  
    1212{
    1313public:
     14    MString &Print(const char *fmt, va_list &ap);
    1415    MString &Print(const char *fmt, ...);
     16    static MString Form(const char *fmt, ...);
    1517
    1618    ClassDef(MString, 1) // Tool to make Form() thread safe against other TStrings
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r5351 r5713  
    101101#include <TStopwatch.h> // TStopwatch
    102102
     103#include "MString.h"
     104
    103105#include "MLog.h"
    104106#include "MLogManip.h"
     
    335337// name (eg. ;1)
    336338//
    337 const char *MTask::GetDescriptor() const
     339const TString MTask::GetDescriptor() const
    338340{
    339341    //
     
    343345    //
    344346    if (fName==ClassName())
    345         return fSerialNumber==0 ? ClassName() : Form("%s;%d", ClassName(), fSerialNumber);
     347        return fSerialNumber==0 ? ClassName() : MString::Form("%s;%d", ClassName(), fSerialNumber);
    346348
    347349    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());
    350352}
    351353
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r5101 r5713  
    8989    Byte_t GetSerialNumber() const           { return fSerialNumber; }
    9090
    91     const char *GetDescriptor() const;
     91    const TString GetDescriptor() const;
    9292
    9393    // Task execution statistics
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r5692 r5713  
    405405        const char *cname = cont->GetName();
    406406        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()));
    408408
    409409        //
  • trunk/MagicSoft/Mars/mhbase/MFillH.cc

    r4997 r5713  
    166166        return;
    167167
    168     fTitle = "Fill " + fHName;
     168    fTitle = Form("Fill %s", fHName.Data());
    169169    if (fParContainerName.IsNull())
    170170        return;
    171171
    172     fTitle += " from " + fParContainerName;
     172    fTitle += Form(" from %s", fParContainerName.Data());
    173173}
    174174
     
    209209
    210210    if (!title)
    211         fTitle = "Fill " + fHName + " from " + par->GetDescriptor();
     211        fTitle = Form("Fill %s from %s", fName.Data(), par->GetDescriptor().Data());
    212212}
    213213
     
    236236        return;
    237237
    238     fTitle = (TString)"Fill " + hist->GetDescriptor();
     238    fTitle = Form("Fill %s", hist->GetDescriptor().Data());
    239239    if (!par)
    240240        return;
    241241
    242     fTitle += " from " + fParContainerName;
     242    fTitle += Form(" from %s", fParContainerName.Data());
    243243}
    244244
     
    265265
    266266    if (!title)
    267         fTitle = (TString)"Fill " + hist->GetDescriptor() + " from " + par->GetDescriptor();
     267        fTitle = Form("Fill %s from %s", hist->GetDescriptor().Data(), par->GetDescriptor().Data());
    268268}
    269269
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc

    r5685 r5713  
    679679  if (overflow > 0.0005*hist->GetEntries())
    680680    {
    681       *fLog << warn << "HiGain Hist-overflow occurred " << overflow
     681      *fLog << warn << "HiGain Hist-overflow " << overflow
    682682            << " times in " << pix.GetName() << " (w/o saturation!) " << endl;
    683683    }
     
    686686  if (overflow > 0.0005*hist->GetEntries())
    687687    {
    688       *fLog << warn << "HiGain Hist-underflow occurred " << overflow
     688      *fLog << warn << "HiGain Hist-underflow " << overflow
    689689            << " times in " << pix.GetName() << " (w/o saturation!) " << endl;
    690690    }
Note: See TracChangeset for help on using the changeset viewer.