[balsa/gtk3] GMutex deprecation cleanup; fixes bgo #677381



commit 2790eb10f8f82650381dc07ac24b12c5f89cb8cd
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 5 15:05:11 2012 -0400

    GMutex deprecation cleanup; fixes bgo #677381
    
    	* libbalsa/imap-server.c (libbalsa_imap_server_init),
    	(libbalsa_imap_server_finalize): deprecation cleanup.
    	* libbalsa/libbalsa-conf.c (lbc_lock), (lbc_unlock): ditto.
    	* libbalsa/mime-stream-shared.c (lbmss_stream_class_init),
    	(libbalsa_mime_stream_shared_lock),
    	(libbalsa_mime_stream_shared_unlock): ditto.

 ChangeLog                     |   11 +++++++++++
 libbalsa/imap-server.c        |   12 ++++++------
 libbalsa/libbalsa-conf.c      |    6 +++---
 libbalsa/mime-stream-shared.c |   18 ++++++++----------
 4 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 738c181..ffffc55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-06-05  Peter Bloomfield
+
+	Deprecation cleanup; fixes bgo #677381
+
+	* libbalsa/imap-server.c (libbalsa_imap_server_init),
+	(libbalsa_imap_server_finalize): deprecation cleanup.
+	* libbalsa/libbalsa-conf.c (lbc_lock), (lbc_unlock): ditto.
+	* libbalsa/mime-stream-shared.c (lbmss_stream_class_init),
+	(libbalsa_mime_stream_shared_lock),
+	(libbalsa_mime_stream_shared_unlock): ditto.
+
 2012-06-03  Peter Bloomfield
 
 	* src/main-window.c: change sensitivity of mail-check button in
diff --git a/libbalsa/imap-server.c b/libbalsa/imap-server.c
index 00c05e1..4fe03fa 100644
--- a/libbalsa/imap-server.c
+++ b/libbalsa/imap-server.c
@@ -65,7 +65,7 @@ struct LibBalsaImapServer_ {
     gboolean offline_mode;
     
 #if defined(BALSA_USE_THREADS)
-    GMutex *lock; /* protects the following members */
+    GMutex lock; /* protects the following members */
 #endif
     guint used_connections;
     GList *used_handles;
@@ -102,9 +102,9 @@ static gboolean connection_cleanup(gpointer ptr);
 static pthread_mutex_t imap_servers_lock = PTHREAD_MUTEX_INITIALIZER;
 #define LOCK_SERVERS()   pthread_mutex_lock(&imap_servers_lock)
 #define UNLOCK_SERVERS() pthread_mutex_unlock(&imap_servers_lock)
-#define LOCK_SERVER(server)    g_mutex_lock((server)->lock)
-#define TRYLOCK_SERVER(server) g_mutex_trylock((server)->lock)
-#define UNLOCK_SERVER(server)  g_mutex_unlock((server)->lock)
+#define LOCK_SERVER(server)    g_mutex_lock(&((server)->lock))
+#define TRYLOCK_SERVER(server) g_mutex_trylock(&((server)->lock))
+#define UNLOCK_SERVER(server)  g_mutex_unlock(&((server)->lock))
 #else
 #define LOCK_SERVERS()
 #define UNLOCK_SERVERS()
@@ -212,7 +212,7 @@ libbalsa_imap_server_init(LibBalsaImapServer * imap_server)
     LIBBALSA_SERVER(imap_server)->protocol = "imap";
     imap_server->key = NULL;
 #if defined(BALSA_USE_THREADS)
-    imap_server->lock = g_mutex_new();
+    g_mutex_init(&imap_server->lock);
 #endif
     imap_server->max_connections = MAX_CONNECTIONS_PER_SERVER;
     imap_server->used_connections = 0;
@@ -250,7 +250,7 @@ libbalsa_imap_server_finalize(GObject * object)
 #endif
     libbalsa_imap_server_force_disconnect(imap_server);
 #if defined(BALSA_USE_THREADS)
-    g_mutex_free(imap_server->lock);
+    g_mutex_clear(&imap_server->lock);
 #endif
     g_free(imap_server->key); imap_server->key = NULL;
 
diff --git a/libbalsa/libbalsa-conf.c b/libbalsa/libbalsa-conf.c
index b724599..e0d8147 100644
--- a/libbalsa/libbalsa-conf.c
+++ b/libbalsa/libbalsa-conf.c
@@ -147,12 +147,12 @@ lbc_init(LibBalsaConf * conf, const gchar * filename,
 }
 
 #ifdef BALSA_USE_THREADS
-static GStaticRecMutex lbc_mutex = G_STATIC_REC_MUTEX_INIT;
+static GRecMutex lbc_mutex;
 
 static void
 lbc_lock(void)
 {
-    g_static_rec_mutex_lock(&lbc_mutex);
+    g_rec_mutex_lock(&lbc_mutex);
     lbc_init(&lbc_conf, "config", ".gnome2");
     lbc_init(&lbc_conf_priv, "config-private", ".gnome2_private");
 }
@@ -160,7 +160,7 @@ lbc_lock(void)
 static void
 lbc_unlock(void)
 {
-    g_static_rec_mutex_unlock(&lbc_mutex);
+    g_rec_mutex_unlock(&lbc_mutex);
 }
 #else                           /* BALSA_USE_THREADS */
 static void
diff --git a/libbalsa/mime-stream-shared.c b/libbalsa/mime-stream-shared.c
index 694af74..6a278ec 100644
--- a/libbalsa/mime-stream-shared.c
+++ b/libbalsa/mime-stream-shared.c
@@ -71,8 +71,8 @@ static GMimeStream *lbmss_stream_substream(GMimeStream * stream,
                                            gint64 start, gint64 end);
 
 static GMimeStreamFsClass *parent_class = NULL;
-static GMutex *lbmss_mutex;
-static GCond *lbmss_cond;
+static GMutex lbmss_mutex;
+static GCond lbmss_cond;
 
 GType
 libbalsa_mime_stream_shared_get_type(void)
@@ -107,8 +107,6 @@ lbmss_stream_class_init(LibBalsaMimeStreamSharedClass * klass)
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
     parent_class = g_type_class_ref(GMIME_TYPE_STREAM_FS);
-    lbmss_mutex  = g_mutex_new();
-    lbmss_cond   = g_cond_new();
 
     object_class->finalize  = lbmss_finalize;
 
@@ -282,12 +280,12 @@ libbalsa_mime_stream_shared_lock(GMimeStream * stream)
     lock = stream_shared->lock;
     thread_self = g_thread_self();
 
-    g_mutex_lock(lbmss_mutex);
+    g_mutex_lock(&lbmss_mutex);
     while (lock->count > 0 && lock->thread != thread_self)
-        g_cond_wait(lbmss_cond, lbmss_mutex);
+        g_cond_wait(&lbmss_cond, &lbmss_mutex);
     ++lock->count;
     lock->thread = thread_self;
-    g_mutex_unlock(lbmss_mutex);
+    g_mutex_unlock(&lbmss_mutex);
 }
 
 /**
@@ -314,10 +312,10 @@ libbalsa_mime_stream_shared_unlock(GMimeStream * stream)
     lock = stream_shared->lock;
     g_return_if_fail(lock->count > 0);
 
-    g_mutex_lock(lbmss_mutex);
+    g_mutex_lock(&lbmss_mutex);
     if (--lock->count == 0)
-        g_cond_signal(lbmss_cond);
-    g_mutex_unlock(lbmss_mutex);
+        g_cond_signal(&lbmss_cond);
+    g_mutex_unlock(&lbmss_mutex);
 }
 
 #endif                          /* BALSA_USE_THREADS */



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