[goffice] Canvas: clean up disposal of GocItems a bit.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Canvas: clean up disposal of GocItems a bit.
- Date: Mon, 17 Mar 2014 12:50:00 +0000 (UTC)
commit a5834f27d1d367862480f5b4a1db6d2ee9433eef
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 17 08:49:17 2014 -0400
Canvas: clean up disposal of GocItems a bit.
ChangeLog | 8 ++++++++
goffice/canvas/goc-canvas.c | 8 +-------
goffice/canvas/goc-item.c | 19 +++++++++++++++++++
3 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2aa0946..c07f0b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-03-17 Morten Welinder <terra gnome org>
+
+ * goffice/canvas/goc-canvas.c (goc_canvas_dispose): Dispose of
+ ->root instead of simply clearing it.
+
+ * goffice/canvas/goc-item.c (goc_item_dispose): Dispose of style
+ context, if we have one.
+
2014-03-16 Morten Welinder <terra gnome org>
* goffice/canvas/goc-polyline.c (goc_polyline_distance): Don't
diff --git a/goffice/canvas/goc-canvas.c b/goffice/canvas/goc-canvas.c
index cf9a26b..d889b03 100644
--- a/goffice/canvas/goc-canvas.c
+++ b/goffice/canvas/goc-canvas.c
@@ -250,13 +250,7 @@ static void
goc_canvas_dispose (GObject *obj)
{
GocCanvas *canvas = GOC_CANVAS (obj);
- GtkStyleContext *context = goc_item_get_style_context (GOC_ITEM (canvas->root));
- goc_group_clear (canvas->root);
- /* we need to set the parent context to NULL for root before unrefing it
- * because Gtk+ calls the "changed" signal when the parent is set to
- * NULL from gtk_style_context_finalize(), and as the ref_count is already
- * NULL, this fires criticals. */
- gtk_style_context_set_parent (context, NULL);
+ g_object_run_dispose (G_OBJECT (canvas->root));
parent_klass->dispose (obj);
}
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index acff12d..a47b642 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -24,6 +24,11 @@
#include <gsf/gsf-impl-utils.h>
#include <glib/gi18n-lib.h>
+#ifdef GOFFICE_WITH_GTK
+static void cb_parent_changed (const GocItem *item);
+#endif
+
+
/**
* SECTION:goc-item
* @short_description: Base canvas item.
@@ -213,6 +218,8 @@ static void
goc_item_dispose (GObject *object)
{
GocItem *item = GOC_ITEM (object);
+ GtkStyleContext *context;
+
if (item->canvas) {
if (item->canvas->last_item == item)
item->canvas->last_item = NULL;
@@ -225,6 +232,18 @@ goc_item_dispose (GObject *object)
if (item->parent != NULL)
goc_group_remove_child (item->parent, item);
+#ifdef GOFFICE_WITH_GTK
+ context = g_object_get_qdata (G_OBJECT (item), quark_style_context);
+ if (context) {
+ g_signal_handlers_disconnect_by_func
+ (object, G_CALLBACK (cb_parent_changed), NULL);
+#ifdef HAVE_GTK_STYLE_CONTEXT_SET_PARENT
+ gtk_style_context_set_parent (context, NULL);
+#endif
+ g_object_set_qdata (object, quark_style_context, NULL);
+ }
+#endif
+
item_parent_class->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]