[evolution-ews/gnome-3-8] Fix crash on addressbook close



commit 45dd3ea143b4ff6eee79e71633e24c3ea1e9606f
Author: David Woodhouse <David Woodhouse intel com>
Date:   Fri May 17 14:47:27 2013 +0100

    Fix crash on addressbook close
    
    In e_book_backend_ews_dispose() we cancel priv->cancellable and then
    immediately free it along with a bunch of other stuff, and *then* wait
    for the update thread to complete.
    
    The update thread then crashes the next time it checks if the (now-freed)
    cancellable is cancelled.
    
    We should first cancel it, *then* wait for the thread, and then free
    everything else. In fact I'm not entirely sure we *should* be freeing
    everything else here; isn't that supposed to be done in the finalize()
    method? But I'll leave it as-is for now...
    (cherry picked from commit a56a32e1044a7932e91425a0398a0ae00c9398a5)

 src/addressbook/e-book-backend-ews.c |   36 +++++++++++++++++----------------
 1 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 49ec794..9d06357 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -3038,8 +3038,26 @@ e_book_backend_ews_dispose (GObject *object)
        bews = E_BOOK_BACKEND_EWS (object);
        priv = bews->priv;
 
-       if (priv->cancellable) {
+       if (priv->cancellable)
                g_cancellable_cancel (priv->cancellable);
+
+       if (priv->dlock) {
+               g_mutex_lock (&priv->dlock->mutex);
+               priv->dlock->exit = TRUE;
+               g_mutex_unlock (&priv->dlock->mutex);
+
+               g_cond_signal (&priv->dlock->cond);
+
+               if (priv->dthread)
+                       g_thread_join (priv->dthread);
+
+               g_mutex_clear (&priv->dlock->mutex);
+               g_cond_clear (&priv->dlock->cond);
+               g_free (priv->dlock);
+               priv->dthread = NULL;
+       }
+
+       if (priv->cancellable) {
                g_object_unref (priv->cancellable);
                priv->cancellable = NULL;
        }
@@ -3069,22 +3087,6 @@ e_book_backend_ews_dispose (GObject *object)
                priv->attachment_dir = NULL;
        }
 
-       if (priv->dlock) {
-               g_mutex_lock (&priv->dlock->mutex);
-               priv->dlock->exit = TRUE;
-               g_mutex_unlock (&priv->dlock->mutex);
-
-               g_cond_signal (&priv->dlock->cond);
-
-               if (priv->dthread)
-                       g_thread_join (priv->dthread);
-
-               g_mutex_clear (&priv->dlock->mutex);
-               g_cond_clear (&priv->dlock->cond);
-               g_free (priv->dlock);
-               priv->dthread = NULL;
-       }
-
        if (priv->summary) {
                g_object_unref (priv->summary);
                priv->summary = NULL;


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