[evolution] Ensure EMailConfigPage::changed signal is emitted in the main/UI thread



commit 1363f90c09c3c228a677a31bec3e8657de16962d
Author: Milan Crha <mcrha redhat com>
Date:   Mon Aug 22 11:55:57 2016 +0200

    Ensure EMailConfigPage::changed signal is emitted in the main/UI thread
    
    The signal is emitted also on any CamelSettings changes of the associated
    CamelService, but some providers, like evolution-mapi, can change the profile
    name of the settings in a dedicated thread. That could lead to a crash, due to
    the EMailConfigAssistant listening to this signal and doing gtk+ calls there.
    
    This had been reported downstream at:
    https://bugzilla.redhat.com/show_bug.cgi?id=1368612

 mail/e-mail-config-page.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/mail/e-mail-config-page.c b/mail/e-mail-config-page.c
index a6047b9..05d87f5 100644
--- a/mail/e-mail-config-page.c
+++ b/mail/e-mail-config-page.c
@@ -23,6 +23,7 @@
 #include <libedataserver/libedataserver.h>
 
 #include <e-util/e-marshal.h>
+#include <e-util/e-util.h>
 
 enum {
        CHANGED,
@@ -200,12 +201,31 @@ e_mail_config_page_compare (GtkWidget *page_a,
        return 0;
 }
 
+static gboolean
+mail_config_page_emit_changed_idle (gpointer user_data)
+{
+       EMailConfigPage *page = user_data;
+
+       g_return_val_if_fail (E_IS_MAIL_CONFIG_PAGE (page), FALSE);
+
+       g_signal_emit (page, signals[CHANGED], 0);
+
+       return FALSE;
+}
+
 void
 e_mail_config_page_changed (EMailConfigPage *page)
 {
        g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
 
-       g_signal_emit (page, signals[CHANGED], 0);
+       if (e_util_is_main_thread (NULL)) {
+               g_signal_emit (page, signals[CHANGED], 0);
+       } else {
+               /* Ensure the signal is emitted in the main/UI thread. */
+               g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+                       mail_config_page_emit_changed_idle,
+                       g_object_ref (page), g_object_unref);
+       }
 }
 
 void


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