Re: Wanted: TObject dtor improvement

Rene Brun (Rene.Brun@cern.ch)
Sat, 14 Nov 1998 10:29:56 +0100


Hi Valery,
I agree with your request. Will look into the best implementation.

Rene Brun

Valery Fine wrote:
>
> Hello list the current TObject dtor looks as follows:
>
> //______________________________________________________________________________
> TObject::~TObject()
> {
> // TObject destructor. Removes object from all canvases and object browsers
> // iff observer bit is on and remove from the global object table.
>
> // if (!TestBit(kNotDeleted))
> // Fatal("~TObject", "object deleted twice");
>
> if (gROOT) {
> if (gROOT->MustClean()) {
> if (gROOT == this) return;
> if (TestBit(kObjInCanvas)) {
> if (gROOT->GetListOfCanvases()) gROOT->GetListOfCanvases()->RecursiveRemove(this);
> if (gROOT->GetListOfBrowsers()) gROOT->GetListOfBrowsers()->RecursiveRemove(this);
> }
> }
> }
>
> fBits &= ~kNotDeleted;
>
> if (fgObjectStat && gObjectTable) gObjectTable->Remove(this);
> }
> ===============
> I think it will be useful to change things as follows:
>
> TObject::~TObject()
> {
> // TObject destructor. Removes object from all "checked" lists (containers ?)
> // if observer bit is on and remove from the global object table.
>
> if (gROOT) {
> if (gROOT->MustClean()) {
> if (gROOT == this) return;
> if (TestBit(kInCheckedList)) {
> TList *checked = gROOT->GetListOfCheckedContainers();
> if (checked) {
> TIter next(checked);
> TList *observer = 0;
> while (observer = (TList *)next())
> observer->RecursiveRemove(this)
> }
> }
> }
> }
>
> fBits &= ~kNotDeleted;
>
> if (fgObjectStat && gObjectTable) gObjectTable->Remove(this);
> }
>
> This allows the user code introduce their own "check in" lists to satisfy their own needs as well not only TCanvas
> and TBrowser.
>
> Valery
> =================================================================
> Dr. Valeri Faine (Fine)
> ------------------- Phone: +1 516 344 7806
> Brookhaven National Laboratory FAX : +1 516 344 4206
> Bldg. 510A /STAR mailto:fine@bnl.gov
> Upton, New York, 11973-5000 http://nicewww.cern.ch/~fine
> USA
>
> Dr. Valery Fine Telex : 911621 dubna su
> -----------
> LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
> 141980 Dubna, Moscow region Fax : +7 09621 6 51 45
> Russia mailto:fine@main1.jinr.dubna.su