[tracker/tracker-0.12] libtracker-common: use GRecMutex if GLib >= 2.31



commit a0ba93f733a78de57401e5d42065254e0dba988a
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Fri Dec 16 11:47:36 2011 +0100

    libtracker-common: use GRecMutex if GLib >= 2.31
    
    Since 2.31, GStaticRecMutex is deprecated.

 src/libtracker-common/tracker-locale.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-locale.c b/src/libtracker-common/tracker-locale.c
index 7947869..2463e40 100644
--- a/src/libtracker-common/tracker-locale.c
+++ b/src/libtracker-common/tracker-locale.c
@@ -45,7 +45,12 @@ static const gchar *locale_names[TRACKER_LOCALE_LAST] = {
 
 /* Already initialized? */
 static gboolean initialized;
+
+#if GLIB_CHECK_VERSION (2,31,0)
+static GRecMutex locales_mutex;
+#else
 static GStaticRecMutex locales_mutex = G_STATIC_REC_MUTEX_INIT;
+#endif
 
 const gchar*
 tracker_locale_get_name (guint i)
@@ -58,7 +63,11 @@ void
 tracker_locale_set (TrackerLocaleID  id,
                     const gchar     *value)
 {
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_rec_mutex_lock (&locales_mutex);
+#else
 	g_static_rec_mutex_lock (&locales_mutex);
+#endif
 
 	if (current_locales[id]) {
 		g_debug ("Locale '%s' was changed from '%s' to '%s'",
@@ -98,7 +107,11 @@ tracker_locale_set (TrackerLocaleID  id,
 		break;
 	}
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_rec_mutex_unlock (&locales_mutex);
+#else
 	g_static_rec_mutex_unlock (&locales_mutex);
+#endif
 }
 
 void
@@ -165,13 +178,21 @@ tracker_locale_get (TrackerLocaleID id)
 
 	g_return_val_if_fail (initialized, NULL);
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_rec_mutex_lock (&locales_mutex);
+#else
 	g_static_rec_mutex_lock (&locales_mutex);
+#endif
 
 	/* Always return a duplicated string, as the locale may change at any
 	 * moment */
 	locale = g_strdup (current_locales[id]);
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_rec_mutex_unlock (&locales_mutex);
+#else
 	g_static_rec_mutex_unlock (&locales_mutex);
+#endif
 
 	return locale;
 }



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