Re: [ROOT] Users Guide 3.05 - GUI deletion ?

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Wed Aug 06 2003 - 22:38:21 MEST


In the each TGCompositeFrame dtor you have to delete the widgets
created, this can be either done via Cleanup() or via deleting a trash
list. When all the dtor's are in order then deleting the fMainFrame will
also recursively call the dtors of all embedded composite frames and
everything will be properly deleted.

Cheers, Fons.



On Wed, 2003-08-06 at 17:29, cstrato wrote:
> Dear Fons
> 
> Thank you for this hint.
> Since all frames are eventually subframes of TGMainFrame, does this
> mean that I have only to call:
>    fMainFrame->Cleanup; delete fMainFrame;
> and all subframes (i.e.more than 350 subframes of my guiapp)
> are deleted correctly?
> 
> Best regards
> Christian
> 
> Fons Rademakers wrote:
> 
> >Best is not to share LayoutHints and to use TGFrame::Cleanup(). Notice
> >that Cleanup() was only introduced a year ago and so does not yet appear
> >in older code examples (need to update guitest). We could add AddFrame
> >with default LayoutHints arguments to make this implicit.
> >
> >Cheers, Fons.
> >
> >
> >
> >On Sat, 2003-07-19 at 19:57, Valeriy Onuchin wrote:
> >  
> >
> >> Hi Christian,
> >>sorry, I was  not correct. All layout hints and frames are 
> >>deleted with http://root.cern.ch/root/htmldoc/TGCompositeFrame.html#TGCompositeFrame:Cleanup
> >>method, not in destructor. I will look at the problem of possible memory leak.
> >>I think adding "reference counting" would help here.
> >> 
> >>    
> >>
> >>>Dear Valeriy
> >>>
> >>>Thank you, too, for your fast reply.
> >>>Nevertheless I am confused, since the link that you mention says:
> >>>"Most of the time, however, you will want to provide specific hints.
> >>>User specified hints can be reused many times and need to be
> >>>destroyed by the user."
> >>>
> >>>Usually, I do the following:
> >>>   fFExpV1 = new TGCompositeFrame(fFTExp, 20, 20, kVerticalFrame);
> >>>   hint = new TGLayoutHints(kLHintsLeft, 1, 2,  0, 2);
> >>>   fFTExp->AddFrame(fFExpV1, hint);
> >>>   fTrash->Add(hint);
> >>>Is this correct? Is it necessary?
> >>>      
> >>>
> >>It is correct and necessary.
> >>
> >>Thanks. Regards. Valeriy
> >>
> >>    
> >>
> >>>Best regards
> >>>Christian
> >>>
> >>>Valeriy Onuchin wrote:
> >>>
> >>>      
> >>>
> >>>>Hi Christian,
> >>>>hframe->AddFrame(draw, new TGLayoutHints(..) -  is correct.
> >>>>TGLayoutHints object will be deleted automatically (as well as "draw" object)
> >>>>when TGCompositeFrame is deleted,  as it is explained in
> >>>>http://root.cern.ch/root/htmldoc/TGCompositeFrame.html#TGCompositeFrame:AddFrame
> >>>>
> >>>>I think it's worth to add new method  (be done asap)
> >>>>TGCompositeFrame::AddFrame(TGFrame *f, ULong_t hints = kLHintsNormal,
> >>>>                                                                       Int_t padleft = 0, Int_t
> >>>>padright = 0,
> >>>>                                                                       Int_t padtop = 0, Int_t
> >>>>padbottom = 0)
> >>>>which will help to eliminate this uncertanty.
> >>>>
> >>>>Regards. Valeriy
> >>>>
> >>>>      > Hi Christian,
> >>>> 
> >>>>
> >>>>        
> >>>>
> >>>>>Ilka will fix the problem in the doc as soon as she will be back from
> >>>>>holidays.
> >>>>>
> >>>>>Valeriy, could you answer about the memory leak?
> >>>>>
> >>>>>Rene
> >>>>>
> >>>>>On Sat, 19 Jul 2003,
> >>>>>cstrato wrote:
> >>>>>
> >>>>>   
> >>>>>
> >>>>>          
> >>>>>
> >>>>>>Dear Rooters
> >>>>>>
> >>>>>>I appreciate the new GUI chapter in the User Guide, too, thank you.
> >>>>>>The only thing I am missing is some note about GUI deletion, i.e.
> >>>>>>how to delete the GUI objects correctly. It would be great, if this
> >>>>>>could be handled, too.
> >>>>>>
> >>>>>>BTW, as far as I understand, some demo code is not correct with
> >>>>>>respect to deletion of GUI classes, e.g.
> >>>>>>hframe->AddFrame(draw, new TGLayoutHints(..));
> >>>>>>In this example, TGLayoutHints will never be deleted?
> >>>>>>
> >>>>>>Best regards
> >>>>>>Christian
> >>>>>>_._._._._._._._._._._._._._._._
> >>>>>>C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
> >>>>>>V.i.e.n.n.a       A.u.s.t.r.i.a
> >>>>>>_._._._._._._._._._._._._._._._
> >>>>>>
> >>>>>>Frankland John wrote:
> >>>>>>
> >>>>>>     
> >>>>>>
> >>>>>>            
> >>>>>>
> >>>>>>>Hello everybody
> >>>>>>>
> >>>>>>>I've just finished reading the long-awaited chapter on GUI creation
> >>>>>>>in the new Users' Manual, this is going to be a great help! Thankyou!
> >>>>>>>
> >>>>>>>However, with as much expectation I turned to the new chapter on the
> >>>>>>>geometry
> >>>>>>>package and what a disappointment! No explanation whatsoever. I have been
> >>>>>>>wanting to interface my detector description classes with the TGeometry
> >>>>>>>classes for a long time, in order to visualise, do tracking etc., but
> >>>>>>>the existing
> >>>>>>>HTML doc & example programmes are just incomprehensible to me.
> >>>>>>>
> >>>>>>>Any chance of a real (and real SIMPLE) manual in the near future ?
> >>>>>>>
> >>>>>>>Thanks a lot
> >>>>>>>John
> >>>>>>>
> >>>>>>>PS. my message about using TClonesArray::ExpandCreate
> >>>>>>>( http://root.cern.ch/root/roottalk/roottalk03/2705.html ) didn't
> >>>>>>>provoke any reaction -
> >>>>>>>is this because noone received it ?
> >>>>>>>--
> >>>>>>>
> >>>>>>>ganil logo <http://www.ganil.fr>
> >>>>>>>John D. Frankland <mailto:frankland@ganil.fr>
> >>>>>>>Beam Coordinator
> >>>>>>>GANIL
> >>>>>>>B.P. 55027
> >>>>>>>14076 CAEN Cedex 05
> >>>>>>>
> >>>>>>>tel: +33 (0)231454628
> >>>>>>>fax: +33 (0)231454665
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>       
> >>>>>>>
> >>>>>>>              
> >>>>>>>
> >>>>>>                 
> >>>>>>
> >>>>>             
> >>>>>
> >>>>
> >>>>         
> >>>>
> >>>
> >>>      
> >>>
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET