Changeset 9532 for trunk


Ignore:
Timestamp:
12/23/09 11:45:35 (15 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9531 r9532  
    1818
    1919                                                 -*-*- 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
    2031
    2132 2009/12/21 Thomas Bretz
  • trunk/MagicSoft/Mars/mbase/MStatusArray.cc

    r9519 r9532  
    1818!   Author(s): Thomas Bretz 03/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2004
     20!   Copyright: MAGIC Software Development, 2000-2009
    2121!
    2222!
     
    5757ClassImp(MStatusArray);
    5858
     59#include <TGraph.h>
     60
    5961using namespace std;
    6062
     
    8587    {
    8688        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);
    9097    }
    9198
     
    122129// --------------------------------------------------------------------------
    123130//
     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//
     135void 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//
     164void 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//
    124177// Try to do a delete of the whole list in a way which is less vulnarable
    125178// to double deletion due to wrongly set bits or other things
  • trunk/MagicSoft/Mars/mbase/MStatusArray.h

    r9519 r9532  
    6262    void Delete(Option_t *option="");
    6363
     64    void RecursiveRemove(TVirtualPad *p, TObject *o);
     65    void RecursiveRemove(TObject *o);
     66
    6467    ClassDef(MStatusArray, 0) // Helper class for status display
    6568};
Note: See TracChangeset for help on using the changeset viewer.