Index: mail/ChangeLog
===================================================================
--- mail/ChangeLog	(revision 35381)
+++ mail/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2008-04-18  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #511337
+
+	* em-format-html.c: (efh_format_done), (efh_format_timeout):
+	Either clear preview content or disable it during formatting message,
+	so users cannot touch buttons of attachments which holds already freed
+	memory structures thus clicking on them can lead to crash.
+
 2008-04-17  Milan Crha  <mcrha@redhat.com>
 
 	** Part of fix for bug #526739
Index: mail/em-format-html.c
===================================================================
--- mail/em-format-html.c	(revision 35381)
+++ mail/em-format-html.c	(working copy)
@@ -1325,6 +1325,10 @@ efh_format_done (struct _format_msg *m)
 
 	m->format->load_http_now = FALSE;
 	m->format->priv->format_id = -1;
+
+	if (m->format->html)
+		gtk_widget_set_sensitive (GTK_WIDGET (m->format->html), TRUE);
+
 	g_signal_emit_by_name(m->format, "complete");
 }
 
@@ -1393,11 +1397,13 @@ efh_format_timeout(struct _format_msg *m
 		mail_msg_unref(m);
 		p->last_part = NULL;
 	} else {
+		/* either clear content or disable widget, so user cannot touch attachment buttons during formatting */
 		if (p->last_part != m->message) {
 			hstream = gtk_html_begin (efh->html);
 			gtk_html_stream_printf (hstream, "<h5>%s</h5>", _("Formatting Message..."));
 			gtk_html_stream_close (hstream, GTK_HTML_STREAM_OK);
-		}
+		} else
+			gtk_widget_set_sensitive (GTK_WIDGET (efh->html), FALSE);
 
 		hstream = NULL;
 		m->estream = (EMHTMLStream *)em_html_stream_new(efh->html, hstream);
