Re: gtk_ui_manager_get_accel_group reference



On Fri, 2007-11-09 at 16:40 +0100, c f wrote:
Hi,

I'm not sure if the following problem is a bug in gtk or it is a 'feature':

Running the following code:

GtkUIManager *uiManager = gtk_ui_manager_new();
GtkAccelGroup *accelGroup = gtk_ui_manager_get_accel_group(uiManager);

g_object_unref(accelGroup);
g_object_unref(uiManager);

will result in an error message:
"GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT
(object)' failed"

this error message is given when the refcounter of the uiManager is decreased.
When  gtk_ui_manager_get_accel_group is called it gives back a
reference to the AccelGroup but the ref count of it is not increased.

Most get_ functions in GTK+ do not do g_object_ref() on the result. It's
entirely normal.

But not all functions do this, and some libraries, such as gstreamer,
clutter and tinymail act differently. You need to read the documentation
for each function really.

(With gtkmm you never need to worry about reference-counting)

And from the error message seams that the UIManager still has a
reference to the AccelGroup object and it tries to free it.

This code works correctly if I increment the ref count manually after
getting the pointer of AccelGroup.

Please could you help to identify if this is a bug or a feature?

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com




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