[tracker/compilation-warnings: 5/13] libtracker-common: use GRecMutex if GLib >= 2.31
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/compilation-warnings: 5/13] libtracker-common: use GRecMutex if GLib >= 2.31
- Date: Fri, 16 Dec 2011 12:44:11 +0000 (UTC)
commit 887793dbb7d29bbc81b1e80e056b0f2a4b608423
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]