diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-04-19 03:43:56 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-04-19 03:52:47 +0800 |
commit | 7a2673a359ed80ba3f3bcd569de108432da18e11 (patch) | |
tree | 5d5562fbc185f30d0c7a341901ec8e91d35ff146 | |
parent | 7dec65de1a2f3c879a53a7a1649b0d8899412a39 (diff) | |
download | gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.tar gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.tar.gz gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.tar.bz2 gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.tar.lz gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.tar.xz gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.tar.zst gsoc2013-evolution-7a2673a359ed80ba3f3bcd569de108432da18e11.zip |
EShellBackend: Rework shutdown delay.
Use g_signal_connect_data() to automatically release the EActivity when
the signal handler is disconnected, and keep the handler ID internally.
This is cleaner than using g_signal_handlers_disconnect_by_func().
-rw-r--r-- | shell/e-shell-backend.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c index f4aed9b28b..31e3809903 100644 --- a/shell/e-shell-backend.c +++ b/shell/e-shell-backend.c @@ -60,6 +60,9 @@ struct _EShellBackendPrivate { gchar *data_dir; gchar *prefer_new_item; + /* This is set to delay shutdown. */ + gulong notify_busy_handler_id; + guint started : 1; }; @@ -96,14 +99,13 @@ shell_backend_notify_busy_cb (EShellBackend *shell_backend, GParamSpec *pspec, EActivity *activity) { - /* Unreferencing the EActivity allows the shell to - * proceed with shutdown. */ if (!e_shell_backend_is_busy (shell_backend)) { - g_signal_handlers_disconnect_by_func ( + /* Disconnecting this signal handler will unreference the + * EActivity and allow the shell to proceed with shutdown. */ + g_signal_handler_disconnect ( shell_backend, - shell_backend_notify_busy_cb, - activity); - g_object_unref (activity); + shell_backend->priv->notify_busy_handler_id); + shell_backend->priv->notify_busy_handler_id = 0; } } @@ -112,13 +114,18 @@ shell_backend_prepare_for_quit_cb (EShell *shell, EActivity *activity, EShellBackend *shell_backend) { - /* Referencing the EActivity delays shutdown; the - * reference count acts like a counting semaphore. */ - if (e_shell_backend_is_busy (shell_backend)) - g_signal_connect ( + if (e_shell_backend_is_busy (shell_backend)) { + gulong handler_id; + + /* Referencing the EActivity delays shutdown; the + * reference count acts like a counting semaphore. */ + handler_id = g_signal_connect_data ( shell_backend, "notify::busy", G_CALLBACK (shell_backend_notify_busy_cb), - g_object_ref (activity)); + g_object_ref (activity), + (GClosureNotify) g_object_unref, 0); + shell_backend->priv->notify_busy_handler_id = handler_id; + } } static GObject * @@ -212,6 +219,12 @@ shell_backend_dispose (GObject *object) priv->prefer_new_item = NULL; } + if (priv->notify_busy_handler_id > 0) { + g_signal_handler_disconnect ( + object, priv->notify_busy_handler_id); + priv->notify_busy_handler_id = 0; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_shell_backend_parent_class)->dispose (object); } |