diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/glade-gtk.c | 22 | ||||
-rw-r--r-- | src/glade-xml-utils.c | 14 |
3 files changed, 27 insertions, 16 deletions
@@ -1,5 +1,12 @@ 2004-10-06 Morten Welinder <terra@gnome.org> + * src/glade-gtk.c (glade_gtk_widget_condition): Fix life cycle of + GtkObjects. + + * src/glade-xml-utils.c (glade_xml_context_destroy): Only + conditionally free xml document. + (glade_xml_context_new_real): New arg "freedoc". + * src/glade-gtk.c (glade_gtk_widget_get_tooltip): Bullet proof. (glade_gtk_notebook_post_create): Actually set the property. diff --git a/src/glade-gtk.c b/src/glade-gtk.c index ebe0e48e..a648382a 100644 --- a/src/glade-gtk.c +++ b/src/glade-gtk.c @@ -111,22 +111,22 @@ glade_gtk_option_menu_set_items (GObject *object, GValue *value) int GLADEGTK_API glade_gtk_widget_condition (GladeWidgetClass *klass) { - GObject *object = g_object_new (klass->type, NULL); + GtkObject *object = (GtkObject*)g_object_new (klass->type, NULL); + gboolean result; /* Only widgets with windows can have tooltips at present. Though buttons seem to be a special case, as they are NO_WINDOW widgets but have InputOnly windows, so tooltip still work. In GTK+ 2 menuitems are like buttons. */ - if (!GTK_WIDGET_NO_WINDOW (object) || GTK_IS_BUTTON (object) || GTK_IS_MENU_ITEM (object)) - { - gtk_object_destroy (GTK_OBJECT (object)); - return TRUE; - } - else - { - gtk_object_destroy (GTK_OBJECT (object)); - return FALSE; - } + result = (!GTK_WIDGET_NO_WINDOW (object) || + GTK_IS_BUTTON (object) || + GTK_IS_MENU_ITEM (object)); + + gtk_object_ref (object); + gtk_object_sink (object); + gtk_object_unref (object); + + return result; } /** diff --git a/src/glade-xml-utils.c b/src/glade-xml-utils.c index 34000ab8..7c300cd1 100644 --- a/src/glade-xml-utils.c +++ b/src/glade-xml-utils.c @@ -31,6 +31,7 @@ struct _GladeXmlDoc struct _GladeXmlContext { GladeXmlDoc *doc; + gboolean freedoc; xmlNsPtr ns; }; @@ -481,12 +482,14 @@ glade_xml_search_child_required (GladeXmlNode *node, const gchar* name) } /* --------------------------- Parse Context ----------------------------*/ -GladeXmlContext * -glade_xml_context_new_real (GladeXmlDoc *doc, xmlNsPtr ns) + +static GladeXmlContext * +glade_xml_context_new_real (GladeXmlDoc *doc, gboolean freedoc, xmlNsPtr ns) { GladeXmlContext *context = g_new0 (GladeXmlContext, 1); context->doc = doc; + context->freedoc = freedoc; context->ns = ns; return context; @@ -496,14 +499,15 @@ GladeXmlContext * glade_xml_context_new (GladeXmlDoc *doc, const gchar *name_space) { /* We are not using the namespace now */ - return glade_xml_context_new_real (doc, NULL); + return glade_xml_context_new_real (doc, FALSE, NULL); } void glade_xml_context_destroy (GladeXmlContext *context) { g_return_if_fail (context != NULL); - xmlFreeDoc ((xmlDoc*)context->doc); + if (context->freedoc) + xmlFreeDoc ((xmlDoc*)context->doc); g_free (context); } @@ -553,7 +557,7 @@ glade_xml_context_new_from_path (const gchar *full_path, return NULL; } - context = glade_xml_context_new_real ((GladeXmlDoc *)doc, name_space); + context = glade_xml_context_new_real ((GladeXmlDoc *)doc, TRUE, name_space); return context; } |