[evolution/evolution-3-12] Bug 731770 - Sometimes crashes when trying to load images in e-mails



commit dd041b9876e39dc04d123f4365cc4f75752a8a1f
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 18 14:07:09 2014 +0200

    Bug 731770 - Sometimes crashes when trying to load images in e-mails

 mail/e-mail-display.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 61751df..27e7b2a 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -505,6 +505,7 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
        GList *head, *link;
        EMailPart *part = NULL;
        GtkWidget *widget = NULL;
+       GWeakRef *weakref;
        gchar *part_id, *type, *object_uri;
 
        part_id = g_hash_table_lookup (param, "data");
@@ -517,8 +518,14 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
 
        display = E_MAIL_DISPLAY (web_view);
 
-       widget = g_hash_table_lookup (display->priv->widgets, part_id);
+       weakref = g_hash_table_lookup (display->priv->widgets, part_id);
+       if (weakref)
+               widget = g_weak_ref_get (weakref);
+
        if (widget != NULL) {
+               /* This cannot be the last reference; thread-safety is assured,
+                  because this runs in the main thread only. */
+               g_object_unref (widget);
                d (printf ("Handeled %s widget request from cache\n", part_id));
                return widget;
        }
@@ -708,7 +715,7 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
 
        g_hash_table_insert (
                display->priv->widgets,
-               g_strdup (object_uri), g_object_ref (widget));
+               g_strdup (object_uri), e_weak_ref_new (widget));
 
 exit:
        if (part != NULL)
@@ -1019,7 +1026,7 @@ mail_display_uri_changed (EMailDisplay *display,
                (GHashFunc) g_str_hash,
                (GEqualFunc) g_str_equal,
                (GDestroyNotify) g_free,
-               (GDestroyNotify) g_object_unref);
+               (GDestroyNotify) e_weak_ref_free);
 }
 
 static void


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