[evolution-data-server] cfs_reload_from_db: CamelSession can be NULL when the folder is in dispose



commit c06a58ed09c579a41e98de97a85b129f1273575d
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 24 12:51:07 2014 +0100

    cfs_reload_from_db: CamelSession can be NULL when the folder is in dispose

 camel/camel-folder-summary.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 3cf711a..90bd255 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -2303,7 +2303,6 @@ cfs_reload_from_db (CamelFolderSummary *summary,
                     GError **error)
 {
        CamelDB *cdb;
-       CamelSession *session;
        CamelStore *parent_store;
        const gchar *folder_name;
        gint ret = 0;
@@ -2318,7 +2317,6 @@ cfs_reload_from_db (CamelFolderSummary *summary,
 
        folder_name = camel_folder_get_full_name (summary->priv->folder);
        parent_store = camel_folder_get_parent_store (summary->priv->folder);
-       session = camel_service_ref_session (CAMEL_SERVICE (parent_store));
        cdb = parent_store->cdb_r;
 
        data.columns_hash = NULL;
@@ -2337,14 +2335,22 @@ cfs_reload_from_db (CamelFolderSummary *summary,
        /* FIXME Convert this to a GTask, submitted through
         *       camel_service_queue_task().  Then it won't
         *       have to call camel_folder_lock/unlock(). */
-       if (summary->priv->need_preview)
-               camel_session_submit_job (
-                       session,
-                       (CamelSessionCallback) preview_update,
-                       g_object_ref (summary->priv->folder),
-                       (GDestroyNotify) g_object_unref);
-
-       g_object_unref (session);
+       if (summary->priv->need_preview) {
+               CamelSession *session;
+
+               /* This may not be available in a case of this being called as part
+                  of CamelSession's dispose, because the CamelService uses GWeakRef
+                  object which is invalidates its content when it reaches the dispose. */
+               session = camel_service_ref_session (CAMEL_SERVICE (parent_store));
+               if (session) {
+                       camel_session_submit_job (
+                               session,
+                               (CamelSessionCallback) preview_update,
+                               g_object_ref (summary->priv->folder),
+                               (GDestroyNotify) g_object_unref);
+                       g_object_unref (session);
+               }
+       }
 
        return ret == 0 ? 0 : -1;
 }


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