[ROOT] Ownership of GUI elements

From: J.D. Frankland (frankland@ganil.fr)
Date: Fri Jun 07 2002 - 23:36:02 MEST


Hello RootPeople,

First: sorry, this is a bit long...

I have succeeded in getting a GUI of the ground by learning from the 
example guitest.cxx
However, one of the things which remains unclear to me is to know 
exactly which TG****
objects I need to delete when any of my frames is closed/deleted etc....

It is explicitly written in the source code that TGLayoutHints need to 
be deleted by the user,
this I do as in the example by putting their pointers in a TList which I 
delete in the dtor.
I thought I understood that any TGCompositeFrame-derived object (which 
includes, I think,
MainFrames, Tabs, HorizontalFrames, VerticalFrames etc.) keeps a track 
of all the frames/widgets which are added to it using AddFrame(...) and 
then deletes them all at the end,
so all of these I should not have to worry about. However, what about 
e.g. TGNumberEntry widgets ? (I have rather a lot of them). In the 
example it is not clear, as it seems that one or two 
TGTextButtons/TGTextEntry widgets are added to the fCleanup TList for 
user-deletion in the dtor, whereas most of the others are left to the 
mother-frame.

The reason I ask is: my GUI is dynamically created to represent and 
configure the structure of a multidetector array, with a set of tabs 
describing different layers, each of these tabs has a set of tabs 
describing the rings in each layer, and on each of these "ring tabs" are 
a set of buttons and TGNumberEntry fields for setting e.g. the number 
and angular ranges of the telescopes in the rings. Every time the 
detector structure is altered by the user (i.e. changing the number of 
telescopes, changing the angles covered by the rings, removing/adding a 
ring...) the GUI must be updated in order to reflect these changes. The 
only way I can see of doing this is to wipe (i.e. delete) everything 
except the MainFrame and reconstruct the whole lot whenever the user 
presses the "Update Array Structure" button. But although I carefully 
delete all my TGLayoutHints I seem to have memory leaks, because 
repeated pushing of the "Update" button gives increasing memory 
occupation by my application, increasingly slow response of the GUI 
redrawing, and eventually segmentation faults (although it doesn't 
actually crash, the buttons just stop working, or the interface goes 
weird...)

Can anyone help ? Is there an easier way to do this ? Can one for 
example link the TGNumberEntry fields to the data member they are 
representing so that they are always automatically up to date without 
intervention from me ? (although this would not be sufficient for 
example in the case where I need to add a new button for a new 
telescope, or remove a ring tab etc. etc. ....)

Thankyou for reading all this
John Frankland



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