After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 138248 - Book: manage() used before it is explained.
Book: manage() used before it is explained.
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: reference documentation
2.4
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-03-26 22:43 UTC by Elijah Newren
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Elijah Newren 2004-03-26 22:43:51 UTC
I had trouble trying to understand the memory management strategy employed by
gtkmm by reading through the docs.  I first read the FAQ, and then the 22
chapter tutorial (plus some of the appendices).  Here's what I thought was
confusing:

First, by reading the FAQ (specifically part 4 of question 1.4), I saw the
statement that, "As a C++ coder you know that pointers should be avoided where
possible."  That made me believe that smart pointers would probably be employed...

I was reading through the tutorial, and came across tutorial/html/ch04s04.html
which used the 'manage' function with no explanation.  I had to google to find
http://mail.gnome.org/archives/gtkmm-list/2002-October/msg00102.html to start to
understand the example (and realize that my initial guess was unfortunately
wrong), though this email (and the few others I looked at) didn't quite answer
all my questions.

Finally, I get to chapter 18 and it answers my questions abou memory management.
 Perhaps I started thinking about memory management a little bit earlier than
others would have, but shouldn't there should at least be a comment back in
chapter 4 when manage is used stating that the manage function will be explained
in chapter 18?  Either that, or remove the references to manage that appear
before chapter 18?

Also, although chapter 18 answered my memory management questions up to that
point, chapter 19 (Glademm and Libglademm) throw another wrench into the works
because nothing I can find states whether the user is responsible for
deallocating the pointers that are returned from get_widget and get_widget_derived.
Comment 1 Murray Cumming 2004-03-27 20:51:31 UTC
So, maybe manage() and RefPtr should be explained in the Basics chapter at the
start. You could copy some of the existing text from the "memory management"
chapter for that - it should just be a condensed version of that chapter.

> nothing I can find states whether the user is responsible for deallocating the
pointers 
> that are returned from get_widget and get_widget_derived.

In the case of top-level windows, I have to investigate this a bit. In general,
you should not expect to delete what you did not new.
Comment 2 Murray Cumming 2004-07-08 16:24:58 UTC
I have added this text to the libglademm chapter:
<para><literal>get_widget()</literal> returns child widgets that are manage()ed
(see the <link linkend="sec-Memory>Memory Management</link> 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.</para>

That should take care of that. I leave the other point to you, as suggested.
Comment 3 Murray Cumming 2004-08-09 18:24:51 UTC
Is there any chance that you will find time to do that?
Comment 4 Elijah Newren 2004-08-09 18:42:14 UTC
I'm sorry for not having responded sooner.  Yes, I will find some time to do
this.    It probably won't be until after Gnome 2.8 is released, though.
Comment 5 Murray Cumming 2004-11-16 20:05:15 UTC
I have added a short description of Gtk::manage() to the Basics, Widgets
section, with a link to the Memory Management chapter. That should deal with
everything.

Thanks for pointing this stuff out.
Comment 6 Elijah Newren 2004-11-16 20:07:55 UTC
Oops!  Sorry for letting everything else get in the way of fixing this and
forgetting about it.  Thanks for fixing it up, though!