[balsa/gtk3] Call lbc_init() only once



commit 3440dfbd2535867c5909ff524b33c3d469acb6f5
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Feb 16 14:52:00 2013 -0500

    Call lbc_init() only once
    
        * libbalsa/libbalsa-conf.c (lbc_lock), (lbc_unlock): call
        lbc_init() only once.

 ChangeLog                |    5 +++++
 libbalsa/libbalsa-conf.c |   24 ++++++++++++------------
 2 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 241cb7a..3af4abf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-16  Peter Bloomfield
+
+       * libbalsa/libbalsa-conf.c (lbc_lock), (lbc_unlock): call
+       lbc_init() only once.
+
 2013-01-15  Peter Bloomfield
 
        * src/main-window.c: emit signal instead of calling NULL class
diff --git a/libbalsa/libbalsa-conf.c b/libbalsa/libbalsa-conf.c
index bf6a51e..ad222f5 100644
--- a/libbalsa/libbalsa-conf.c
+++ b/libbalsa/libbalsa-conf.c
@@ -152,38 +152,38 @@ static GRecMutex lbc_mutex;
 #else                           /* GLIB_CHECK_VERSION(2, 32, 0) */
 static GStaticRecMutex lbc_mutex = G_STATIC_REC_MUTEX_INIT;
 #endif                          /* GLIB_CHECK_VERSION(2, 32, 0) */
+#endif                          /* BALSA_USE_THREADS */
 
 static void
 lbc_lock(void)
 {
+    static gboolean initialized = FALSE;
+
+#ifdef BALSA_USE_THREADS
 #if GLIB_CHECK_VERSION(2, 32, 0)
     g_rec_mutex_lock(&lbc_mutex);
 #else                           /* GLIB_CHECK_VERSION(2, 32, 0) */
     g_static_rec_mutex_lock(&lbc_mutex);
 #endif                          /* GLIB_CHECK_VERSION(2, 32, 0) */
-    lbc_init(&lbc_conf, "config", ".gnome2");
-    lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
+#endif                          /* BALSA_USE_THREADS */
+    if (!initialized) {
+        lbc_init(&lbc_conf, "config", ".gnome2");
+        lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
+        initialized = TRUE;
+    }
 }
 
 static void
 lbc_unlock(void)
 {
+#ifdef BALSA_USE_THREADS
 #if GLIB_CHECK_VERSION(2, 32, 0)
     g_rec_mutex_unlock(&lbc_mutex);
 #else                           /* GLIB_CHECK_VERSION(2, 32, 0) */
     g_static_rec_mutex_unlock(&lbc_mutex);
 #endif                          /* GLIB_CHECK_VERSION(2, 32, 0) */
-}
-#else                           /* BALSA_USE_THREADS */
-static void
-lbc_lock(void)
-{
-    lbc_init(&lbc_conf, "config", ".gnome2");
-    lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
-}
-
-#define lbc_unlock()
 #endif                          /* BALSA_USE_THREADS */
+}
 
 /* 
  * Call @func for each group that begins with @prefix.


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