Re: [ROOT] Safely deleting objects being browsed?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 23 2002 - 08:52:29 MEST


Hi Conrad,

If you have posted a list to a folder and then want to delete the list,
you should do;
   l->Delete();
   delete l;

The first statement will take care of removing the entries in the list
from the browser automatically. Executing only the second statement is not
sufficient.

There is however still a problem with the browser in some complex
combinations when the objects hierachy is in the left pane and the right
pane of the browser. This problem will be fixed soon in CVS.

Rene Brun

On 22 Oct 2002, Conrad Steenberg wrote:

> Hi
> 
> I'm trying to browse a TList in a TBrowser, with the list's contents
> being possibly dynamic. How do I safely remove the contents of the list
> so that the TBrowser(s) get notified of the change and doesn't cause
> segfaults?
> 
> E.g.:
> TFolder *g= gROOT->GetRootFolder()->AddFolder("Test","Test folder");
> gROOT->GetListOfBrowsables()->Add((TObject*)g,"Test");
> TList *l=new TList();
> 
> This adds the list and makes it browsable. Adding new objects to the
> list works fine. Then remove the list:
> g->RecursiveRemove(l);
> 
> This doesn't remove the list, and doing
> delete l;
> has the predictable effect of causing a segfault (when clicking on the
> subfolder TList), since there is still a dangling link to the removed
> object in the browser somewhere.
> 
> Any ideas?
> 
> Thanks!
> 
> Conrad
> 
> 
> -- 
> *-----------------------------------------*
> | Conrad Steenberg                        |
> | Caltech, Mail Code 356-48               |
> | Pasadena, CA, 91125                     |
> | e-mail: conrad@hep.caltech.edu          |
> | Tel: (626) 395-8758                     |
> *-----------------------------------------*
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:15 MET