[balsa/gtk3] Use a mutex to serialize dialogs



commit 2f9bfd2b8bf3942fd50baeb3080c07d8cced281a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Feb 26 18:18:49 2013 -0500

    Use a mutex to serialize dialogs
    
        * src/balsa-app.c (ask_password): use a mutex to make sure that
        only one dialog pops up at a time.

 ChangeLog       |    5 +++++
 src/balsa-app.c |   15 ++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7ca5287..6f60394 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-02-26  Peter Bloomfield
 
+       * src/balsa-app.c (ask_password): use a mutex to make sure that
+       only one dialog pops up at a time.
+
+2013-02-26  Peter Bloomfield
+
        * libbalsa/mailbox_local.c (lbm_local_save_tree_real),
        (lbm_local_queue_save_tree): check that the message tree has
        changed in the idle handler, instead of in the scheduler.
diff --git a/src/balsa-app.c b/src/balsa-app.c
index d4a0318..66e8664 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -228,15 +228,9 @@ ask_password(LibBalsaServer *server, LibBalsaMailbox *mbox)
     
     password = NULL;
     if (mbox) {
-       gboolean is_sub_thread = libbalsa_am_i_subthread();
-
-       if (is_sub_thread)
-           gdk_threads_enter();
        gtk_tree_model_foreach(GTK_TREE_MODEL(balsa_app.mblist_tree_store),
                               (GtkTreeModelForeachFunc)
                               set_passwd_from_matching_server, server);
-       if (is_sub_thread)
-           gdk_threads_leave();
 
        if (server->passwd != NULL) {
            password = server->passwd;
@@ -246,8 +240,15 @@ ask_password(LibBalsaServer *server, LibBalsaMailbox *mbox)
 
     if (!password)
 #ifdef BALSA_USE_THREADS
-       return (pthread_self() == libbalsa_get_main_thread()) ?
+    {
+        G_LOCK_DEFINE_STATIC(ask_password);
+
+        G_LOCK(ask_password);
+       password = (pthread_self() == libbalsa_get_main_thread()) ?
             ask_password_real(server, mbox) : ask_password_mt(server, mbox);
+        G_UNLOCK(ask_password);
+       return password;
+    }
 #else
        return ask_password_real(server, mbox);
 #endif


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