Re: gtkmm::builder - derived child widget's destructor is not called



Hey Kjell,

thanks for the reply.
I already filed a bug report, but seriously, this might result in vast
memory leaks and makes Gtk::Builder almost unusable...

Moritz

Am 08.06.14 17:10, schrieb Kjell Ahlstedt:
Your question is not stupid. I believe Gtk::Builder::get_widget() and
Gtk::Builder::get_widget_derived() handle reference counts in the wrong
way.

Gtk::Builder::get_widget() adds a reference each time it's called.
Gtk::Builder::get_widget_derived() adds a reference the first time it's
called on a certain widget. Other gtkmm methods that return a Widget*
don't add references. Adding references is appropriate for methods that
return a Glib::RefPtr<Something>, but not for methods that return a
plain Something pointer.

If you like, you can file a bug report. Unfortunately there is a risk
with fixing the bug before the release of gtkmm 4 (which is probably not
soon). A fix might break working programs, because some users of gtkmm
might have adapted their programs to the present behaviour by adding
some widget->unreference().

Kjell

2014-06-06 08:42, Moritz Peter skrev:
Hello everybody,

I'm using gtk::builder to create a user-interface. To illustrate my
problem I simplified the interface to a window containing only one
button. I retrieve both widgets (window and button) using
"get_widget_derived" since they are modified by the code.
My problem arises at the end of the program, when the widgets should be
deleted.
The manual states that "toplevel" widgets (windows and dialogs) must be
deleted by the user, so I delete the window as prescribed. As the button
is inside a container (the window) I expect the button to be managed and
therefore being deleted automatically. This is not the case. The
destructor of the button is never called.
What is my mistake? Or is this a bug?

Attached you'll find a simple test program that you can compile using
g++ `pkg-config --libs --cflags gtkmm-3.0` gladetest.cpp
There you will directly see my problem.

I hope, I'm not bothering you with my stupid question.
Thanks in advance.

Moritz





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]