aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-04-06 08:07:32 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-04-06 08:07:32 +0800
commit90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b (patch)
treebab94ef2680c912344d3c92a0a3d8284749e38aa /mail
parente5ec7f858bf942a5bc4441528579810cb18e8220 (diff)
downloadgsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.tar
gsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.tar.gz
gsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.tar.bz2
gsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.tar.lz
gsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.tar.xz
gsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.tar.zst
gsoc2013-evolution-90b9db7b785e83b3e55a1d511b9a491d6dfd1a4b.zip
EMailSidebar: Avoid runtime warnings in dispose().
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-sidebar.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index f0678f7fdf..b8dc823648 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -36,6 +36,8 @@
struct _EMailSidebarPrivate {
GKeyFile *key_file; /* not owned */
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
};
enum {
@@ -199,10 +201,13 @@ mail_sidebar_get_property (GObject *object,
static void
mail_sidebar_constructed (GObject *object)
{
+ EMailSidebarPrivate *priv;
GtkTreeSelection *selection;
GtkTreeView *tree_view;
GtkTreeModel *model;
+ priv = E_MAIL_SIDEBAR_GET_PRIVATE (object);
+
/* Chain up to parent's constructed() property. */
G_OBJECT_CLASS (e_mail_sidebar_parent_class)->constructed (object);
@@ -213,6 +218,12 @@ mail_sidebar_constructed (GObject *object)
em_folder_tree_model_set_selection (
EM_FOLDER_TREE_MODEL (model), selection);
+ /* Keep an internal reference to these since we're connecting
+ * signal handlers to them. Retrieving them during dispose()
+ * does not guarantee we get the same instances back. */
+ priv->model = g_object_ref (model);
+ priv->selection = g_object_ref (selection);
+
g_signal_connect (
model, "loaded-row",
G_CALLBACK (mail_sidebar_model_loaded_row_cb), object);
@@ -225,16 +236,25 @@ mail_sidebar_constructed (GObject *object)
static void
mail_sidebar_dispose (GObject *object)
{
- GtkTreeSelection *selection;
- GtkTreeView *tree_view;
- GtkTreeModel *model;
+ EMailSidebarPrivate *priv;
- tree_view = GTK_TREE_VIEW (object);
- model = gtk_tree_view_get_model (tree_view);
- selection = gtk_tree_view_get_selection (tree_view);
+ priv = E_MAIL_SIDEBAR_GET_PRIVATE (object);
- g_signal_handlers_disconnect_by_func (model, mail_sidebar_model_loaded_row_cb, object);
- g_signal_handlers_disconnect_by_func (selection, mail_sidebar_selection_changed_cb, object);
+ if (priv->model != NULL) {
+ g_signal_handlers_disconnect_by_func (
+ priv->model,
+ mail_sidebar_model_loaded_row_cb, object);
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
+
+ if (priv->selection != NULL) {
+ g_signal_handlers_disconnect_by_func (
+ priv->selection,
+ mail_sidebar_selection_changed_cb, object);
+ g_object_unref (priv->selection);
+ priv->selection = NULL;
+ }
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_mail_sidebar_parent_class)->dispose (object);