aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-threads.c')
-rw-r--r--mail/mail-threads.c90
1 files changed, 77 insertions, 13 deletions
diff --git a/mail/mail-threads.c b/mail/mail-threads.c
index 8fe170eea2..6643b75615 100644
--- a/mail/mail-threads.c
+++ b/mail/mail-threads.c
@@ -278,11 +278,7 @@ mail_operation_queue (const mail_operation_spec * spec, gpointer input,
g_free (msg);
gnome_dialog_set_close (GNOME_DIALOG (err_dialog),
TRUE);
- GDK_THREADS_ENTER ();
- gnome_dialog_run_and_close (GNOME_DIALOG (err_dialog));
- GDK_THREADS_LEAVE ();
- /*gtk_widget_destroy (err_dialog); */
- /*gtk_widget_show (GTK_WIDGET (err_dialog));*/
+ mail_dialog_run_and_close (GNOME_DIALOG (err_dialog));
g_warning ("Setup failed for `%s': %s",
clur->infinitive,
@@ -522,6 +518,77 @@ mail_operations_get_status (int *busy_return,
*message_return = current_message;
}
+/**
+ * mail_dialog_run_and_close:
+ *
+ * A wrapper for gnome_dialog... that will Do The Right Thing
+ * wrt the GDK lock.
+ **/
+
+gint
+mail_dialog_run_and_close (GnomeDialog *dlg)
+{
+ gint ret;
+ gboolean unlock = FALSE;
+
+ /*g_message ("DLG: IN: r_a_c");*/
+
+ /*if (inside_read_msg || gtk_main_level() == 1)
+ * GDK_THREADS_ENTER ();
+ */
+
+ if (gdk_threads_mutex && g_mutex_trylock (gdk_threads_mutex))
+ unlock = TRUE;
+
+ ret = gnome_dialog_run_and_close (dlg);
+
+ /*if (inside_read_msg || gtk_main_level() == 1)
+ * GDK_THREADS_LEAVE();
+ */
+
+ if (unlock)
+ g_mutex_unlock (gdk_threads_mutex);
+
+ /*g_message ("DLG: OUT: r_a_c");*/
+
+ return ret;
+}
+
+/**
+ * mail_dialog_run:
+ *
+ * Analogous to above.
+ **/
+
+gint
+mail_dialog_run (GnomeDialog *dlg)
+{
+ gint ret;
+ gboolean unlock = FALSE;
+
+ /*g_message ("DLG: IN: run");*/
+
+ /*if (inside_read_msg || gtk_main_level() == 1)
+ * GDK_THREADS_ENTER();
+ */
+
+ if (gdk_threads_mutex && g_mutex_trylock (gdk_threads_mutex))
+ unlock = TRUE;
+
+ ret = gnome_dialog_run (dlg);
+
+ /*if (inside_read_msg || gtk_main_level() == 1)
+ * GDK_THREADS_LEAVE();
+ */
+
+ if (unlock)
+ g_mutex_unlock (gdk_threads_mutex);
+
+ /*g_message ("DLG: OUT: run");*/
+
+ return ret;
+}
+
/* ** Static functions **************************************************** */
static void check_dispatcher (void)
@@ -688,7 +755,7 @@ read_msg (GIOChannel * source, GIOCondition condition, gpointer userdata)
* it is as we are in the main thread right now.
*/
- GDK_THREADS_ENTER ();
+ /*g_message ("DLG: IN: read_msg");*/
switch (msg->type) {
case STARTING:
@@ -750,8 +817,9 @@ read_msg (GIOChannel * source, GIOCondition condition, gpointer userdata)
break;
}
- GDK_THREADS_LEAVE ();
+ /*g_message ("DLG: OUT: read_msg");*/
g_free (msg);
+
return TRUE;
}
@@ -822,9 +890,7 @@ show_error (com_msg_t * msg)
* only GDK_THREADS_ENTER were recursive...
*/
- /*GDK_THREADS_ENTER ();*/
- gnome_dialog_run_and_close (GNOME_DIALOG (err_dialog));
- /*GDK_THREADS_LEAVE ();*/
+ mail_dialog_run_and_close (GNOME_DIALOG (err_dialog));
/* Allow the other thread to proceed */
@@ -862,9 +928,7 @@ get_password (com_msg_t * msg)
button = -1;
} else {
*(msg->reply) = NULL;
- /*GDK_THREADS_ENTER ();*/
- button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
- /*GDK_THREADS_LEAVE ();*/
+ button = mail_dialog_run_and_close (GNOME_DIALOG (dialog));
}
if (button == 1 || *(msg->reply) == NULL) {