[evolution-ews] Bug #706151 - Crash under mail_config_ews_ooo_page_display_settings()



commit f54455e0dee22f7a0ffa06c76b18e6da12d9ffb5
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 23 17:53:39 2013 +0200

    Bug #706151 - Crash under mail_config_ews_ooo_page_display_settings()

 .../e-mail-config-ews-delegates-page.c             |   41 +++++++++----------
 src/configuration/e-mail-config-ews-ooo-page.c     |   41 +++++++++----------
 2 files changed, 38 insertions(+), 44 deletions(-)
---
diff --git a/src/configuration/e-mail-config-ews-delegates-page.c 
b/src/configuration/e-mail-config-ews-delegates-page.c
index f6c6adb..0e8920d 100644
--- a/src/configuration/e-mail-config-ews-delegates-page.c
+++ b/src/configuration/e-mail-config-ews-delegates-page.c
@@ -58,6 +58,8 @@ struct _EMailConfigEwsDelegatesPagePrivate {
        EwsDelegateDeliver deliver_to;
        GMutex delegates_lock;
 
+       GCancellable *refresh_cancellable;
+
        GtkWidget *users_tree_view;                     /* not referenced */
        GtkWidget *add_button;                          /* not referenced */
        GtkWidget *remove_button;                       /* not referenced */
@@ -420,30 +422,16 @@ mail_config_ews_delegates_page_dispose (GObject *object)
 
        priv = E_MAIL_CONFIG_EWS_DELEGATES_PAGE_GET_PRIVATE (object);
 
-       if (priv->registry != NULL) {
-               g_object_unref (priv->registry);
-               priv->registry = NULL;
-       }
-
-       if (priv->account_source != NULL) {
-               g_object_unref (priv->account_source);
-               priv->account_source = NULL;
+       if (priv->refresh_cancellable) {
+               g_cancellable_cancel (priv->refresh_cancellable);
+               g_clear_object (&priv->refresh_cancellable);
        }
 
-       if (priv->collection_source != NULL) {
-               g_object_unref (priv->collection_source);
-               priv->collection_source = NULL;
-       }
-
-       if (priv->identity_source != NULL) {
-               g_object_unref (priv->identity_source);
-               priv->identity_source = NULL;
-       }
-
-       if (priv->connection) {
-               g_object_unref (priv->connection);
-               priv->connection = NULL;
-       }
+       g_clear_object (&priv->registry);
+       g_clear_object (&priv->account_source);
+       g_clear_object (&priv->collection_source);
+       g_clear_object (&priv->identity_source);
+       g_clear_object (&priv->connection);
 
        g_slist_free_full (priv->orig_delegates, (GDestroyNotify) ews_delegate_info_free);
        priv->orig_delegates = NULL;
@@ -1526,6 +1514,9 @@ mail_config_ews_delegates_page_try_password_sync (ESourceAuthenticator *auth,
        const gchar *mailbox;
        GError *local_error = NULL;
 
+       if (g_cancellable_set_error_if_cancelled (cancellable, error))
+               return E_SOURCE_AUTHENTICATION_ERROR;
+
        page = E_MAIL_CONFIG_EWS_DELEGATES_PAGE (auth);
        mailbox = mail_config_ews_delegates_page_get_mailbox (page);
        settings = mail_config_ews_delegates_page_get_settings (page);
@@ -1705,9 +1696,15 @@ e_mail_config_ews_delegates_page_refresh (EMailConfigEwsDelegatesPage *page)
        source = e_mail_config_ews_delegates_page_get_collection_source (page);
        authenticator = E_SOURCE_AUTHENTICATOR (page);
 
+       if (page->priv->refresh_cancellable) {
+               g_cancellable_cancel (page->priv->refresh_cancellable);
+               g_clear_object (&page->priv->refresh_cancellable);
+       }
+
        activity = e_mail_config_activity_page_new_activity (
                E_MAIL_CONFIG_ACTIVITY_PAGE (page));
        cancellable = e_activity_get_cancellable (activity);
+       page->priv->refresh_cancellable = g_object_ref (cancellable);
 
        e_activity_set_text (
                activity, _("Retrieving \"Delegates\" settings"));
diff --git a/src/configuration/e-mail-config-ews-ooo-page.c b/src/configuration/e-mail-config-ews-ooo-page.c
index acc958d..db99434 100644
--- a/src/configuration/e-mail-config-ews-ooo-page.c
+++ b/src/configuration/e-mail-config-ews-ooo-page.c
@@ -51,6 +51,8 @@ struct _EMailConfigEwsOooPagePrivate {
        EEwsOofSettings *oof_settings;
        GMutex oof_settings_lock;
 
+       GCancellable *refresh_cancellable;
+
        /* to not save unchanged state */
        gboolean changed;
 
@@ -373,30 +375,16 @@ mail_config_ews_ooo_page_dispose (GObject *object)
 
        priv = E_MAIL_CONFIG_EWS_OOO_PAGE_GET_PRIVATE (object);
 
-       if (priv->registry != NULL) {
-               g_object_unref (priv->registry);
-               priv->registry = NULL;
-       }
-
-       if (priv->account_source != NULL) {
-               g_object_unref (priv->account_source);
-               priv->account_source = NULL;
+       if (priv->refresh_cancellable) {
+               g_cancellable_cancel (priv->refresh_cancellable);
+               g_clear_object (&priv->refresh_cancellable);
        }
 
-       if (priv->collection_source != NULL) {
-               g_object_unref (priv->collection_source);
-               priv->collection_source = NULL;
-       }
-
-       if (priv->identity_source != NULL) {
-               g_object_unref (priv->identity_source);
-               priv->identity_source = NULL;
-       }
-
-       if (priv->oof_settings != NULL) {
-               g_object_unref (priv->oof_settings);
-               priv->oof_settings = NULL;
-       }
+       g_clear_object (&priv->registry);
+       g_clear_object (&priv->account_source);
+       g_clear_object (&priv->collection_source);
+       g_clear_object (&priv->identity_source);
+       g_clear_object (&priv->oof_settings);
 
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (e_mail_config_ews_ooo_page_parent_class)->
@@ -816,6 +804,9 @@ mail_config_ews_ooo_page_try_password_sync (ESourceAuthenticator *auth,
        const gchar *mailbox;
        GError *local_error = NULL;
 
+       if (g_cancellable_set_error_if_cancelled (cancellable, error))
+               return E_SOURCE_AUTHENTICATION_ERROR;
+
        page = E_MAIL_CONFIG_EWS_OOO_PAGE (auth);
        mailbox = mail_config_ews_ooo_page_get_mailbox (page);
        settings = mail_config_ews_ooo_page_get_settings (page);
@@ -991,9 +982,15 @@ e_mail_config_ews_ooo_page_refresh (EMailConfigEwsOooPage *page)
        source = e_mail_config_ews_ooo_page_get_collection_source (page);
        authenticator = E_SOURCE_AUTHENTICATOR (page);
 
+       if (page->priv->refresh_cancellable) {
+               g_cancellable_cancel (page->priv->refresh_cancellable);
+               g_clear_object (&page->priv->refresh_cancellable);
+       }
+
        activity = e_mail_config_activity_page_new_activity (
                E_MAIL_CONFIG_ACTIVITY_PAGE (page));
        cancellable = e_activity_get_cancellable (activity);
+       page->priv->refresh_cancellable = g_object_ref (cancellable);
 
        e_activity_set_text (
                activity, _("Retrieving \"Out of Office\" settings"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]