Deleting widgets loaded using libglademm
- From: Tomasz Olszewski <olszewst gmail com>
- To: gtkmm-list gnome org
- Subject: Deleting widgets loaded using libglademm
- Date: Tue, 09 Jan 2007 21:25:33 +0100
gtkmm documentation seems a bit confusing when it comes to libglademm.
"The widgets are owned by the |Gnome::Glade::Xml| instance, and will be
deleted automatically when it is deleted, when the last copy of the
smartpointer goes out of scope."
For me this means that I don't have to worry about widget deletion
because it will be done automatically. Great, no risk of memory leak!
Let's read on. On the next page there is a paragraph that confused me a
lot. Let me quote it here:
|"get_widget()| returns child widgets that are |manage()|ed (see the
chapter), so they will be deleted when their parent container is
deleted. So, if you get only a child widget from libglademm, instead of
a whole window, then you must either put it in a |Container| or delete
it. |Windows| (such as |Dialogs|) can not be managed because they have
no parent container, so you must delete them at some point."
Basically it says that only child widgets will be deleted automatically
because their lifetime is managed by their parents. All other widgets
*must* be deleted by hand. What happened to the Gnome::Glade::Xml
smartpointer then? Wasn't it supposed to perform such deletion when
being destroyed? Perhaps I should understand this part of the
documentation as: "You *can* delete widgets loaded with libglademm by
yourself, but if you won't, no memory leaks will appear, because the Xml
smartpointer eventually takes care of any pending deletion. What is
more, if you do delete a widget by hand, there is no double deletion
risk"? What's the correct interpretation?
] [Thread Prev