[evolution] mail_session_dispose: First free folders, only then stores



commit aceed006fdfbe40bdfd4816dd2baab0f27259246
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 24 12:52:48 2014 +0100

    mail_session_dispose: First free folders, only then stores
    
    CamelFolder holds a weak reference to its parent CamelStore, thus
    if the store is freed before the folder, then the folder cannot
    access it, which can lead to crashes.

 libemail-engine/e-mail-session.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 2460f9b..42605ea 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -901,6 +901,24 @@ mail_session_dispose (GObject *object)
                priv->folder_cache = NULL;
        }
 
+       g_ptr_array_set_size (priv->local_folders, 0);
+       g_ptr_array_set_size (priv->local_folder_uris, 0);
+
+       if (priv->preparing_flush > 0) {
+               g_source_remove (priv->preparing_flush);
+               priv->preparing_flush = 0;
+       }
+
+       if (priv->local_store != NULL) {
+               g_object_unref (priv->local_store);
+               priv->local_store = NULL;
+       }
+
+       if (priv->vfolder_store != NULL) {
+               g_object_unref (priv->vfolder_store);
+               priv->vfolder_store = NULL;
+       }
+
        if (priv->registry != NULL) {
                g_signal_handler_disconnect (
                        priv->registry,
@@ -925,24 +943,6 @@ mail_session_dispose (GObject *object)
                priv->registry = NULL;
        }
 
-       if (priv->local_store != NULL) {
-               g_object_unref (priv->local_store);
-               priv->local_store = NULL;
-       }
-
-       if (priv->vfolder_store != NULL) {
-               g_object_unref (priv->vfolder_store);
-               priv->vfolder_store = NULL;
-       }
-
-       g_ptr_array_set_size (priv->local_folders, 0);
-       g_ptr_array_set_size (priv->local_folder_uris, 0);
-
-       if (priv->preparing_flush > 0) {
-               g_source_remove (priv->preparing_flush);
-               priv->preparing_flush = 0;
-       }
-
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (e_mail_session_parent_class)->dispose (object);
 }


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