[evolution/webkit: 102/154] Fix crash caused by previous commit



commit 158bde6046748b8e1838f3b82fda92d06c083f8b
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Jan 5 19:52:10 2012 +0100

    Fix crash caused by previous commit
    
    The idle callback handler didn't return FALSE so it was called multiple times,
    even when the attachment was already destroyed causing random crashes and weird
    error messages.

 mail/em-format-html-display.c |   37 ++++++++++++++++---------------------
 1 files changed, 16 insertions(+), 21 deletions(-)
---
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 81c72f3..e2c9163 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -74,7 +74,7 @@
 #define d(x)
 
 struct _EMFormatHTMLDisplayPrivate {
-		EFlag *attachment_loaded;
+                gint dummy;
 };
 
 /* TODO: move the dialogue elsehwere */
@@ -407,7 +407,7 @@ efhd_xpkcs7mime_button (EMFormat *emf,
 
 struct attachment_load_data {
 	EAttachment *attachment;
-	EMFormatHTMLDisplay *efhd;
+	EFlag *flag;
 };
 
 static void
@@ -424,21 +424,19 @@ attachment_loaded (EAttachment *attachment,
 	if (!E_IS_SHELL_WINDOW (window))
 		window = NULL;
 	
-	e_attachment_load_handle_error (data->attachment, res, window);
-
-	e_flag_set (data->efhd->priv->attachment_loaded);
+        e_attachment_load_handle_error (data->attachment, res, window);
 
-	g_object_unref (data->attachment);
-	g_object_unref (data->efhd);
-	g_free (data);
+	e_flag_set (data->flag);
 }
 
 /* Idle callback */
-static void
+static gboolean
 load_attachment_idle (struct attachment_load_data *data)
 {
 	e_attachment_load_async (data->attachment,
 		(GAsyncReadyCallback) attachment_loaded, data);
+
+        return FALSE;
 }
 
 
@@ -556,16 +554,20 @@ efhd_parse_attachment (EMFormat *emf,
 		}
 	}
 
-	e_flag_clear (efhd->priv->attachment_loaded);
-
 	load_data = g_new0 (struct attachment_load_data, 1);
 	load_data->attachment = g_object_ref (puri->attachment);
-	load_data->efhd = g_object_ref (efhd);
+	load_data->flag = e_flag_new ();
+
+        e_flag_clear (load_data->flag);
 
 	/* e_attachment_load_async must be called from main thread */
         g_idle_add ((GSourceFunc) load_attachment_idle, load_data);
 
-	e_flag_wait (efhd->priv->attachment_loaded);
+	e_flag_wait (load_data->flag);
+
+        e_flag_free (load_data->flag);
+        g_object_unref (load_data->attachment);
+        g_free (load_data);
 
 	if (size != 0) {
 		GFileInfo *fileinfo;
@@ -844,11 +846,6 @@ efhd_finalize (GObject *object)
 	efhd = EM_FORMAT_HTML_DISPLAY (object);
 	g_return_if_fail (efhd != NULL);
 
-	if (efhd->priv->attachment_loaded) {
-		e_flag_free (efhd->priv->attachment_loaded);
-		efhd->priv->attachment_loaded = NULL;
-	}
-
 	/* Chain up to parent's finalize() method. */
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -882,9 +879,7 @@ efhd_init (EMFormatHTMLDisplay *efhd)
 
 	efhd->priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efhd);
 
-	efhd->priv->attachment_loaded = e_flag_new ();
-
-	/* we want to convert url's etc */
+        /* we want to convert url's etc */
 	EM_FORMAT_HTML (efhd)->text_html_flags |=
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;



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