[gimp] app: make destroying a GimpFilteredContainer not crash
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make destroying a GimpFilteredContainer not crash
- Date: Thu, 1 Dec 2011 20:16:12 +0000 (UTC)
commit ed1ed0e6bc9bfa72ee255b9820fc960f71b2abc9
Author: Michael Natterer <mitch gimp org>
Date: Thu Dec 1 21:12:55 2011 +0100
app: make destroying a GimpFilteredContainer not crash
It was never disconnecting from any of the src_container objects'
signals.
GimpFilteredContainer: unref the src_container in finalize() instead
of dispose() because the parent dispose() impl now needs it via
calling gimp_container_clear().
GimpTaggedContainer: implement GimpContainer::clear() and disconnect
from all the src_container objects' signals.
app/core/gimpfilteredcontainer.c | 15 +++++++++++++-
app/core/gimptaggedcontainer.c | 39 +++++++++++++++++++++++++++++++++----
2 files changed, 48 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpfilteredcontainer.c b/app/core/gimpfilteredcontainer.c
index 59ca612..f594709 100644
--- a/app/core/gimpfilteredcontainer.c
+++ b/app/core/gimpfilteredcontainer.c
@@ -39,6 +39,7 @@ enum
static void gimp_filtered_container_constructed (GObject *object);
static void gimp_filtered_container_dispose (GObject *object);
+static void gimp_filtered_container_finalize (GObject *object);
static void gimp_filtered_container_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -82,6 +83,7 @@ gimp_filtered_container_class_init (GimpFilteredContainerClass *klass)
g_object_class->constructed = gimp_filtered_container_constructed;
g_object_class->dispose = gimp_filtered_container_dispose;
+ g_object_class->finalize = gimp_filtered_container_finalize;
g_object_class->set_property = gimp_filtered_container_set_property;
g_object_class->get_property = gimp_filtered_container_get_property;
@@ -157,12 +159,23 @@ gimp_filtered_container_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (filtered_container->src_container,
gimp_filtered_container_src_thaw,
filtered_container);
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+static void
+gimp_filtered_container_finalize (GObject *object)
+{
+ GimpFilteredContainer *filtered_container = GIMP_FILTERED_CONTAINER (object);
+
+ if (filtered_container->src_container)
+ {
g_object_unref (filtered_container->src_container);
filtered_container->src_container = NULL;
}
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/app/core/gimptaggedcontainer.c b/app/core/gimptaggedcontainer.c
index 2676296..0f279d8 100644
--- a/app/core/gimptaggedcontainer.c
+++ b/app/core/gimptaggedcontainer.c
@@ -42,6 +42,8 @@ static void gimp_tagged_container_dispose (GObject
static gint64 gimp_tagged_container_get_memsize (GimpObject *object,
gint64 *gui_size);
+static void gimp_tagged_container_clear (GimpContainer *container);
+
static void gimp_tagged_container_src_add (GimpFilteredContainer *filtered_container,
GimpObject *object);
static void gimp_tagged_container_src_remove (GimpFilteredContainer *filtered_container,
@@ -79,12 +81,15 @@ gimp_tagged_container_class_init (GimpTaggedContainerClass *klass)
{
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
+ GimpContainerClass *container_class = GIMP_CONTAINER_CLASS (klass);
GimpFilteredContainerClass *filtered_class = GIMP_FILTERED_CONTAINER_CLASS (klass);
g_object_class->dispose = gimp_tagged_container_dispose;
gimp_object_class->get_memsize = gimp_tagged_container_get_memsize;
+ container_class->clear = gimp_tagged_container_clear;
+
filtered_class->src_add = gimp_tagged_container_src_add;
filtered_class->src_remove = gimp_tagged_container_src_remove;
filtered_class->src_freeze = gimp_tagged_container_src_freeze;
@@ -145,6 +150,34 @@ gimp_tagged_container_get_memsize (GimpObject *object,
}
static void
+gimp_tagged_container_clear (GimpContainer *container)
+{
+ GimpFilteredContainer *filtered_container = GIMP_FILTERED_CONTAINER (container);
+ GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (container);
+ GList *list;
+
+ for (list = GIMP_LIST (filtered_container->src_container)->list;
+ list;
+ list = g_list_next (list))
+ {
+ g_signal_handlers_disconnect_by_func (list->data,
+ gimp_tagged_container_tag_added,
+ tagged_container);
+ g_signal_handlers_disconnect_by_func (list->data,
+ gimp_tagged_container_tag_removed,
+ tagged_container);
+ }
+
+ if (tagged_container->tag_ref_counts)
+ {
+ g_hash_table_remove_all (tagged_container->tag_ref_counts);
+ tagged_container->tag_count = 0;
+ }
+
+ GIMP_CONTAINER_CLASS (parent_class)->clear (container);
+}
+
+static void
gimp_tagged_container_src_add (GimpFilteredContainer *filtered_container,
GimpObject *object)
{
@@ -201,11 +234,7 @@ gimp_tagged_container_src_remove (GimpFilteredContainer *filtered_container,
static void
gimp_tagged_container_src_freeze (GimpFilteredContainer *filtered_container)
{
- GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container);
-
- gimp_container_clear (GIMP_CONTAINER (tagged_container));
- g_hash_table_remove_all (tagged_container->tag_ref_counts);
- tagged_container->tag_count = 0;
+ gimp_container_clear (GIMP_CONTAINER (filtered_container));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]