[devhelp/gnome-3-8] book-tree: disconnect signals when the object gets disposed
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/gnome-3-8] book-tree: disconnect signals when the object gets disposed
- Date: Mon, 8 Apr 2013 13:44:27 +0000 (UTC)
commit 8b968aa529d86fec12f5844e901140add71bbcd4
Author: Aleksander Morgado <aleksander lanedo com>
Date: Mon Apr 8 15:18:32 2013 +0200
book-tree: disconnect signals when the object gets disposed
Fixes part of https://bugzilla.gnome.org/show_bug.cgi?id=697541
src/dh-book-tree.c | 65 +++++++++++++++++++++++++++++++++------------------
1 files changed, 42 insertions(+), 23 deletions(-)
---
diff --git a/src/dh-book-tree.c b/src/dh-book-tree.c
index 991699c..4cb5bc0 100644
--- a/src/dh-book-tree.c
+++ b/src/dh-book-tree.c
@@ -40,6 +40,13 @@ typedef struct {
GtkTreeStore *store;
DhBookManager *book_manager;
DhLink *selected_link;
+
+ /* Signals */
+ guint book_created_id;
+ guint book_deleted_id;
+ guint book_enabled_id;
+ guint book_disabled_id;
+ guint group_by_language_id;
} DhBookTreePriv;
static void dh_book_tree_class_init (DhBookTreeClass *klass);
@@ -77,9 +84,21 @@ static gint signals[LAST_SIGNAL] = { 0 };
static void
book_tree_finalize (GObject *object)
{
- DhBookTreePriv *priv = GET_PRIVATE (object);
-
- g_object_unref (priv->store);
+ DhBookTreePriv *priv = GET_PRIVATE (object);
+
+ /* Disconnect signals */
+ if (g_signal_handler_is_connected (priv->book_manager, priv->book_created_id))
+ g_signal_handler_disconnect (priv->book_manager, priv->book_created_id);
+ if (g_signal_handler_is_connected (priv->book_manager, priv->book_deleted_id))
+ g_signal_handler_disconnect (priv->book_manager, priv->book_deleted_id);
+ if (g_signal_handler_is_connected (priv->book_manager, priv->book_enabled_id))
+ g_signal_handler_disconnect (priv->book_manager, priv->book_enabled_id);
+ if (g_signal_handler_is_connected (priv->book_manager, priv->book_disabled_id))
+ g_signal_handler_disconnect (priv->book_manager, priv->book_disabled_id);
+ if (g_signal_handler_is_connected (priv->book_manager, priv->group_by_language_id))
+ g_signal_handler_disconnect (priv->book_manager, priv->group_by_language_id);
+
+ g_object_unref (priv->store);
g_object_unref (priv->book_manager);
G_OBJECT_CLASS (dh_book_tree_parent_class)->finalize (object);
@@ -674,26 +693,26 @@ dh_book_tree_new (DhBookManager *book_manager)
priv->book_manager = g_object_ref (book_manager);
- g_signal_connect (priv->book_manager,
- "book-created",
- G_CALLBACK (book_tree_book_created_or_enabled_cb),
- tree);
- g_signal_connect (priv->book_manager,
- "book-deleted",
- G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
- tree);
- g_signal_connect (priv->book_manager,
- "book-enabled",
- G_CALLBACK (book_tree_book_created_or_enabled_cb),
- tree);
- g_signal_connect (priv->book_manager,
- "book-disabled",
- G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
- tree);
- g_signal_connect (priv->book_manager,
- "notify::group-by-language",
- G_CALLBACK (book_tree_group_by_language_cb),
- tree);
+ priv->book_created_id = g_signal_connect (priv->book_manager,
+ "book-created",
+ G_CALLBACK (book_tree_book_created_or_enabled_cb),
+ tree);
+ priv->book_deleted_id = g_signal_connect (priv->book_manager,
+ "book-deleted",
+ G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
+ tree);
+ priv->book_enabled_id = g_signal_connect (priv->book_manager,
+ "book-enabled",
+ G_CALLBACK (book_tree_book_created_or_enabled_cb),
+ tree);
+ priv->book_disabled_id = g_signal_connect (priv->book_manager,
+ "book-disabled",
+ G_CALLBACK (book_tree_book_deleted_or_disabled_cb),
+ tree);
+ priv->group_by_language_id = g_signal_connect (priv->book_manager,
+ "notify::group-by-language",
+ G_CALLBACK (book_tree_group_by_language_cb),
+ tree);
book_tree_populate_tree (tree);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]