[libgda/LIBGDA_5.0] Handle deprecated symbols for Glib 2.32



commit d5e55c0858cb481eb455b03dd87dd0275f589c39
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Dec 29 08:07:24 2011 +0100

    Handle deprecated symbols for Glib 2.32

 libgda/gda-config.c                        |    6 +
 libgda/gda-connection.c                    |  172 +++++++++++++++++++++-
 libgda/gda-data-handler.c                  |   18 ++-
 libgda/gda-data-model.c                    |   17 ++-
 libgda/gda-data-pivot.c                    |   36 +++++-
 libgda/gda-holder.c                        |    4 +
 libgda/gda-init.c                          |    4 +
 libgda/gda-lockable.c                      |   16 ++-
 libgda/gda-log.c                           |    6 +
 libgda/gda-meta-store.c                    |   24 ++-
 libgda/gda-mutex.c                         |  112 ++++++++++++++
 libgda/gda-mutex.h                         |    4 +
 libgda/gda-set.c                           |    8 +
 libgda/gda-sql-builder.c                   |   11 +-
 libgda/gda-value.c                         |    9 +
 libgda/handlers/gda-handler-numerical.c    |    6 +-
 libgda/sqlite/gda-sqlite-provider.c        |   34 +++--
 libgda/sqlite/gda-sqlite-recordset.c       |    4 +
 libgda/thread-wrapper/gda-thread-wrapper.c |  220 ++++++++++++++++++++++++++-
 tools/browser/browser-connection-priv.h    |    4 +
 tools/browser/browser-connection.c         |   36 +++++
 tools/browser/browser-page.c               |   17 ++-
 tools/browser/browser-perspective.c        |   16 ++-
 tools/browser/common/objects-cloud.c       |    8 +-
 24 files changed, 723 insertions(+), 69 deletions(-)
---
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index 01d9f30..73b3a07 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -140,9 +140,15 @@ static void lock_notify_changes (void);
 static void unlock_notify_changes (void);
 #endif
 
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex gda_rmutex;
+#define GDA_CONFIG_LOCK() g_rec_mutex_lock(&gda_rmutex)
+#define GDA_CONFIG_UNLOCK() g_rec_mutex_unlock(&gda_rmutex)
+#else
 static GStaticRecMutex gda_mutex = G_STATIC_REC_MUTEX_INIT;
 #define GDA_CONFIG_LOCK() g_static_rec_mutex_lock(&gda_mutex)
 #define GDA_CONFIG_UNLOCK() g_static_rec_mutex_unlock(&gda_mutex)
+#endif
 
 /* GdaServerProvider for SQLite as a shortcut, available
  * even if the SQLite provider is not installed
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 8fb8c50..66521a5 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -104,10 +104,15 @@ struct _GdaConnectionPrivate {
 
 	/* multi threading locking */
 	GThread              *unique_possible_thread; /* non NULL => only that thread can use this connection */
+#if GLIB_CHECK_VERSION(2,31,7)
+	GCond                 unique_possible_cond;
+	GMutex                object_mutex;
+	GRecMutex             rmutex;
+#else
 	GCond                *unique_possible_cond;
 	GMutex               *object_mutex;
 	GdaMutex             *mutex;
-
+#endif
 	/* Asynchronous statement execution */
 	guint                 next_task_id; /* starts at 1 as 0 is an error */
 	GArray               *waiting_tasks; /* array of CncTask pointers to tasks to be executed */
@@ -126,7 +131,11 @@ typedef struct {
 	guint task_id; /* ID assigned by GdaConnection object */
 	guint prov_task_id; /* ID assigned by GdaServerProvider */
 	gboolean being_processed; /* TRUE if currently being processed */
+#if GLIB_CHECK_VERSION(2,31,7)
+	GRecMutex rmutex;
+#else
 	GMutex *mutex;
+#endif
 	GdaStatement *stmt; /* statement to execute */
 	GdaStatementModelUsage model_usage;
 	GType *col_types;
@@ -142,8 +151,13 @@ typedef struct {
 static CncTask *cnc_task_new (guint id, GdaStatement *stmt, GdaStatementModelUsage model_usage, 
 			      GType *col_types, GdaSet *params, gboolean need_last_insert_row);
 static void     cnc_task_free (CncTask *task);
+#if GLIB_CHECK_VERSION(2,31,7)
+#define         cnc_task_lock(task) g_rec_mutex_lock (&((task)->rmutex))
+#define         cnc_task_unlock(task) g_rec_mutex_unlock (&((task)->rmutex))
+#else
 #define         cnc_task_lock(task) g_mutex_lock ((task)->mutex)
 #define         cnc_task_unlock(task) g_mutex_unlock ((task)->mutex)
+#endif
 
 static void add_exec_time_to_object (GObject *obj, GTimer *timer);
 
@@ -460,9 +474,15 @@ gda_connection_init (GdaConnection *cnc, G_GNUC_UNUSED GdaConnectionClass *klass
 
 	cnc->priv = g_new0 (GdaConnectionPrivate, 1);
 	cnc->priv->unique_possible_thread = NULL;
-	cnc->priv->unique_possible_cond = NULL;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_init (&cnc->priv->object_mutex);
+	g_rec_mutex_init (&cnc->priv->rmutex);
+	g_cond_init (& cnc->priv->unique_possible_cond);
+#else
 	cnc->priv->object_mutex = g_mutex_new ();
 	cnc->priv->mutex = gda_mutex_new ();
+	cnc->priv->unique_possible_cond = NULL;
+#endif
 	cnc->priv->provider_obj = NULL;
 	cnc->priv->dsn = NULL;
 	cnc->priv->cnc_string = NULL;
@@ -588,11 +608,16 @@ gda_connection_finalize (GObject *object)
 	g_free (cnc->priv->cnc_string);
 	g_free (cnc->priv->auth_string);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_cond_clear (& cnc->priv->unique_possible_cond);
+	g_mutex_clear (& cnc->priv->object_mutex);
+#else
 	if (cnc->priv->unique_possible_cond)
 		g_cond_free (cnc->priv->unique_possible_cond);
 	if (cnc->priv->object_mutex)
 		g_mutex_free (cnc->priv->object_mutex);
 	gda_mutex_free (cnc->priv->mutex);
+#endif
 
 	g_free (cnc->priv);
 	cnc->priv = NULL;
@@ -677,20 +702,37 @@ gda_connection_set_property (GObject *object,
 
                 switch (param_id) {
 		case PROP_THREAD_OWNER:
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_mutex_lock (&cnc->priv->object_mutex);
+			g_rec_mutex_lock (&cnc->priv->rmutex);
+#else
 			g_mutex_lock (cnc->priv->object_mutex);
 			gda_mutex_lock (cnc->priv->mutex);
+#endif
 			cnc->priv->unique_possible_thread = g_value_get_pointer (value);
 #ifdef GDA_DEBUG_CNC_LOCK
 			g_print ("Unique set to %p\n", cnc->priv->unique_possible_thread);
 #endif
+#if GLIB_CHECK_VERSION(2,31,7)
+#ifdef GDA_DEBUG_CNC_LOCK
+			g_print ("Signalling on %p\n", cnc->priv->unique_possible_cond);
+#endif
+			g_cond_broadcast (& cnc->priv->unique_possible_cond);
+#else
 			if (cnc->priv->unique_possible_cond) {
 #ifdef GDA_DEBUG_CNC_LOCK
 				g_print ("Signalling on %p\n", cnc->priv->unique_possible_cond);
 #endif
 				g_cond_broadcast (cnc->priv->unique_possible_cond);
 			}
+#endif
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_rec_mutex_unlock (&cnc->priv->rmutex);
+			g_mutex_unlock (&cnc->priv->object_mutex);
+#else
 			gda_mutex_unlock (cnc->priv->mutex);
 			g_mutex_unlock (cnc->priv->object_mutex);
+#endif
 			break;
                 case PROP_DSN: {
 			const gchar *datasource = g_value_get_string (value);
@@ -776,22 +818,38 @@ gda_connection_set_property (GObject *object,
                 case PROP_OPTIONS: {
 			GdaConnectionOptions flags;
 			flags = g_value_get_flags (value);
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_rec_mutex_lock (&cnc->priv->rmutex);
+#else
 			gda_mutex_lock (cnc->priv->mutex);
+#endif
 			_gda_thread_connection_set_data (cnc, NULL);
 			if (cnc->priv->provider_data &&
 			    ((flags & (~GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE)) !=
 			     (cnc->priv->options & (~GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE)))) {
 				g_warning (_("Can't set the '%s' property once the connection is opened"),
 					   pspec->name);
+#if GLIB_CHECK_VERSION(2,31,7)
+				g_rec_mutex_unlock (&cnc->priv->rmutex);
+#else
 				gda_mutex_unlock (cnc->priv->mutex);
+#endif
 				return;
 			}
 			cnc->priv->options = flags;
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_rec_mutex_unlock (&cnc->priv->rmutex);
+#else
 			gda_mutex_unlock (cnc->priv->mutex);
+#endif
 			break;
 		}
 		case PROP_META_STORE:
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_rec_mutex_lock (&cnc->priv->rmutex);
+#else
 			gda_mutex_lock (cnc->priv->mutex);
+#endif
 			if (cnc->priv->meta_store) {
 				g_object_unref (cnc->priv->meta_store);
 				cnc->priv->meta_store = NULL;
@@ -806,7 +864,11 @@ gda_connection_set_property (GObject *object,
 					g_object_set (G_OBJECT (cdata->sub_connection), "meta-store",
 						      cnc->priv->meta_store, NULL);
 			}
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_rec_mutex_unlock (&cnc->priv->rmutex);
+#else
 			gda_mutex_unlock (cnc->priv->mutex);
+#endif
 			break;
 		case PROP_IS_THREAD_WRAPPER:
 			cnc->priv->is_thread_wrapper = g_value_get_boolean (value);
@@ -979,25 +1041,42 @@ cnc_task_new (guint id, GdaStatement *stmt, GdaStatementModelUsage model_usage,
 		task->params = gda_set_copy (params);
 	task->need_last_insert_row = need_last_insert_row;
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_init (&(task->rmutex));
+#else
 	task->mutex = g_mutex_new ();
+#endif
+
 	return task;
 }
 
 static void
 task_stmt_reset_cb (G_GNUC_UNUSED GdaStatement *stmt, CncTask *task)
 {
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(task->rmutex));
+#else
 	g_mutex_lock (task->mutex);
+#endif
 	g_signal_handlers_disconnect_by_func (task->stmt,
 					      G_CALLBACK (task_stmt_reset_cb), task);
 	g_object_unref (task->stmt);
 	task->stmt = NULL;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(task->rmutex));
+#else
 	g_mutex_unlock (task->mutex);
+#endif
 }
 
 static void
 cnc_task_free (CncTask *task)
 {
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(task->rmutex));
+#else
 	g_mutex_lock (task->mutex);
+#endif
 	if (task->stmt) {
 		g_signal_handlers_disconnect_by_func (task->stmt,
 						      G_CALLBACK (task_stmt_reset_cb), task);
@@ -1016,8 +1095,13 @@ cnc_task_free (CncTask *task)
 	if (task->exec_timer)
 		g_timer_destroy (task->exec_timer);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(task->rmutex));
+	g_rec_mutex_clear (&(task->rmutex));
+#else
 	g_mutex_unlock (task->mutex);
 	g_mutex_free (task->mutex);
+#endif
 	g_free (task);
 }
 
@@ -1486,6 +1570,9 @@ gda_connection_open_sqlite (const gchar *directory, const gchar *filename, gbool
 	return cnc;
 }
 
+#if GLIB_CHECK_VERSION(2,31,7)
+/* this is not necessary anymore */
+#else
 typedef struct {
 	gboolean thread_exists;
 	GThread *looked_up_thread;
@@ -1497,6 +1584,7 @@ all_threads_func (GThread *thread, ThreadLookupData *data)
 	if (thread == data->looked_up_thread)
 		data->thread_exists = TRUE;
 }
+#endif
 
 /**
  * gda_connection_open:
@@ -1564,6 +1652,12 @@ gda_connection_open (GdaConnection *cnc, GError **error)
 
 	if (PROV_CLASS (cnc->priv->provider_obj)->limiting_thread &&
 	    (PROV_CLASS (cnc->priv->provider_obj)->limiting_thread != g_thread_self ())) {
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_PROVIDER_ERROR,
+			     "%s", _("Provider does not allow usage from this thread"));
+		gda_connection_unlock ((GdaLockable*) cnc);
+		return FALSE;
+#else
 		ThreadLookupData data;
 		data.thread_exists = FALSE;
 		data.looked_up_thread = PROV_CLASS (cnc->priv->provider_obj)->limiting_thread;
@@ -1581,6 +1675,7 @@ gda_connection_open (GdaConnection *cnc, GError **error)
 			 * thread */
 			PROV_CLASS (cnc->priv->provider_obj)->limiting_thread = g_thread_self ();
 		}
+#endif
 	}
 
 	if (!PROV_CLASS (cnc->priv->provider_obj)->open_connection) {
@@ -2489,7 +2584,11 @@ gda_connection_add_event (GdaConnection *cnc, GdaConnectionEvent *event)
 	g_return_if_fail (GDA_IS_CONNECTION (cnc));
 	g_return_if_fail (GDA_IS_CONNECTION_EVENT (event));
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (& cnc->priv->rmutex);
+#else
 	gda_mutex_lock (cnc->priv->mutex);
+#endif
 
 	/* clear external list of events */
 	if (cnc->priv->events_list) {
@@ -2544,7 +2643,11 @@ gda_connection_add_event (GdaConnection *cnc, GdaConnectionEvent *event)
 #ifdef GDA_DEBUG_NO
 	dump_events_array (cnc);
 #endif
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (& cnc->priv->rmutex);
+#else
 	gda_mutex_unlock (cnc->priv->mutex);
+#endif
 }
 
 /**
@@ -6181,12 +6284,20 @@ prepared_stms_foreach_func (GdaStatement *gda_stmt, G_GNUC_UNUSED GdaPStmt *prep
 static void
 statement_weak_notify_cb (GdaConnection *cnc, GdaStatement *stmt)
 {
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (& cnc->priv->rmutex);
+#else
 	gda_mutex_lock (cnc->priv->mutex);
+#endif
 
 	g_assert (cnc->priv->prepared_stmts);
 	g_hash_table_remove (cnc->priv->prepared_stmts, stmt);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (& cnc->priv->rmutex);
+#else
 	gda_mutex_unlock (cnc->priv->mutex);
+#endif
 }
 
 
@@ -6349,8 +6460,11 @@ gda_connection_get_meta_store (GdaConnection *cnc)
 	GdaMetaStore *store = NULL;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_lock (& cnc->priv->object_mutex);
+#else
 	g_mutex_lock (cnc->priv->object_mutex);
+#endif
 	if (!cnc->priv->meta_store) {
 		ThreadConnectionData *cdata = NULL;
 		if (cnc->priv->is_thread_wrapper) {
@@ -6368,8 +6482,11 @@ gda_connection_get_meta_store (GdaConnection *cnc)
 		}
 	}
 	store = cnc->priv->meta_store;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_unlock (& cnc->priv->object_mutex);
+#else
 	g_mutex_unlock (cnc->priv->object_mutex);
-	
+#endif	
 	return store;
 }
 
@@ -6394,14 +6511,26 @@ gda_connection_lock (GdaLockable *lockable)
 {
 	GdaConnection *cnc = (GdaConnection *) lockable;
 	
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (& cnc->priv->rmutex);
+#else
 	gda_mutex_lock (cnc->priv->mutex);
+#endif
 	if (cnc->priv->unique_possible_thread && 
 	    (cnc->priv->unique_possible_thread != g_thread_self ())) {
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (& cnc->priv->rmutex);
+		g_mutex_lock (& cnc->priv->object_mutex);
+#else
 		gda_mutex_unlock (cnc->priv->mutex);
 		g_mutex_lock (cnc->priv->object_mutex);
+#endif
 
+#if GLIB_CHECK_VERSION(2,31,7)
+#else
 		if (!cnc->priv->unique_possible_cond)
 			cnc->priv->unique_possible_cond = g_cond_new ();
+#endif
 
 		while (1) {
 			if (cnc->priv->unique_possible_thread &&
@@ -6411,13 +6540,27 @@ gda_connection_lock (GdaLockable *lockable)
 					 cnc->priv->unique_possible_thread, cnc->priv->unique_possible_cond,
 					 cnc->priv->object_mutex);
 #endif
+#if GLIB_CHECK_VERSION(2,31,7)
+				gint64 end_time;
+				end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
+				while (! g_cond_wait_until (& cnc->priv->unique_possible_cond,
+							    & cnc->priv->object_mutex, end_time));
+#else
 				g_cond_wait (cnc->priv->unique_possible_cond,
 					     cnc->priv->object_mutex);
+#endif
 			}
+#if GLIB_CHECK_VERSION(2,31,7)
+			else if (g_rec_mutex_trylock (& cnc->priv->rmutex)) {
+				g_mutex_unlock (& cnc->priv->object_mutex);
+				break;
+			}
+#else
 			else if (gda_mutex_trylock (cnc->priv->mutex)) {
 				g_mutex_unlock (cnc->priv->object_mutex);
 				break;
 			}
+#endif
 		}
 	}
 }
@@ -6434,11 +6577,19 @@ gda_connection_trylock (GdaLockable *lockable)
 	gboolean retval;
 	GdaConnection *cnc = (GdaConnection *) lockable;
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	retval = g_rec_mutex_trylock (& cnc->priv->rmutex);
+#else
 	retval = gda_mutex_trylock (cnc->priv->mutex);
+#endif
 	if (retval && cnc->priv->unique_possible_thread &&
 	    (cnc->priv->unique_possible_thread != g_thread_self ())) {
 		retval = FALSE;
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (& cnc->priv->rmutex);
+#else
 		gda_mutex_unlock (cnc->priv->mutex);
+#endif
 	}
 	return retval;
 }
@@ -6451,8 +6602,11 @@ static void
 gda_connection_unlock  (GdaLockable *lockable)
 {
 	GdaConnection *cnc = (GdaConnection *) lockable;
-	
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (& cnc->priv->rmutex);
+#else
 	gda_mutex_unlock (cnc->priv->mutex);
+#endif
 }
 
 static gchar *
@@ -6815,11 +6969,19 @@ _gda_thread_connection_data_free (ThreadConnectionData *cdata)
 void
 _gda_thread_connection_set_data (GdaConnection *cnc, ThreadConnectionData *cdata)
 {
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (& cnc->priv->rmutex);
+#else
 	gda_mutex_lock (cnc->priv->mutex);
+#endif
 	if (cnc->priv->th_data)
 		_gda_thread_connection_data_free (cnc->priv->th_data);
 	cnc->priv->th_data = cdata;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (& cnc->priv->rmutex);
+#else
 	gda_mutex_unlock (cnc->priv->mutex);
+#endif
 }
 
 ThreadConnectionData *
diff --git a/libgda/gda-data-handler.c b/libgda/gda-data-handler.c
index 554734b..d5564ff 100644
--- a/libgda/gda-data-handler.c
+++ b/libgda/gda-data-handler.c
@@ -28,7 +28,15 @@
 #include "handlers/gda-handler-time.h"
 #include "handlers/gda-handler-type.h"
 
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex init_rmutex;
+#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
+#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
+#else
 static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+#define MUTEX_LOCK() g_static_rec_mutex_lock(&init_mutex)
+#define MUTEX_UNLOCK() g_static_rec_mutex_unlock(&init_mutex)
+#endif
 static void gda_data_handler_iface_init (gpointer g_class);
 
 GType
@@ -49,13 +57,13 @@ gda_data_handler_get_type (void)
 			(GInstanceInitFunc) NULL,
 			0
 		};
-		
-		g_static_rec_mutex_lock (&init_mutex);
+
+		MUTEX_LOCK();
 		if (type == 0) {
 			type = g_type_register_static (G_TYPE_INTERFACE, "GdaDataHandler", &info, 0);
 			g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
 		}
-		g_static_rec_mutex_unlock (&init_mutex);
+		MUTEX_UNLOCK();
 	}
 	return type;
 }
@@ -66,11 +74,11 @@ gda_data_handler_iface_init (G_GNUC_UNUSED gpointer g_class)
 {
 	static gboolean initialized = FALSE;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	if (! initialized) {
 		initialized = TRUE;
 	}
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 }
 
 /**
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index b0a9306..0112319 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -58,8 +58,15 @@
 #include "csv.h"
 
 extern gchar *gda_lang_locale;
-
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex init_rmutex;
+#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
+#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
+#else
 static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+#define MUTEX_LOCK() g_static_rec_mutex_lock(&init_mutex)
+#define MUTEX_UNLOCK() g_static_rec_mutex_unlock(&init_mutex)
+#endif
 static void gda_data_model_class_init (gpointer g_class);
 
 static xmlNodePtr gda_data_model_to_xml_node (GdaDataModel *model, const gint *cols, gint nb_cols, 
@@ -107,12 +114,12 @@ gda_data_model_get_type (void)
 			0
 		};
 		
-		g_static_rec_mutex_lock (&init_mutex);
+		MUTEX_LOCK();
 		if (type == 0) {
 			type = g_type_register_static (G_TYPE_INTERFACE, "GdaDataModel", &info, 0);
 			g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
 		}
-		g_static_rec_mutex_unlock (&init_mutex);
+		MUTEX_UNLOCK();
 	}
 	return type;
 }
@@ -122,7 +129,7 @@ gda_data_model_class_init (G_GNUC_UNUSED gpointer g_class)
 {
 	static gboolean initialized = FALSE;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	if (! initialized) {
 		/**
 		 * GdaDataModel::changed
@@ -217,7 +224,7 @@ gda_data_model_class_init (G_GNUC_UNUSED gpointer g_class)
 
 		initialized = TRUE;
 	}
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 }
 
 static gboolean
diff --git a/libgda/gda-data-pivot.c b/libgda/gda-data-pivot.c
index 55761a2..a7b4c97 100644
--- a/libgda/gda-data-pivot.c
+++ b/libgda/gda-data-pivot.c
@@ -860,20 +860,42 @@ aggregate_handle_double (CellData *cdata, gdouble val)
 }
 
 static gboolean
-aggregate_handle_char (CellData *cdata, gchar val)
+aggregate_handle_char (CellData *cdata,
+#if GLIB_CHECK_VERSION(2,31,7)
+		       gint8 val
+#else
+		       gchar val
+#endif
+		       )
 {
 	if (cdata->data_value) {
+#if GLIB_CHECK_VERSION(2,31,7)
+		gint8 eval = 0;
+#else
 		gchar eval = 0;
+#endif
 		if (G_VALUE_TYPE (cdata->data_value) == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+			eval = g_value_get_schar (cdata->data_value);
+#else
 			eval = g_value_get_char (cdata->data_value);
+#endif
 		switch (cdata->aggregate) {
 		case GDA_DATA_PIVOT_MIN:
 			if (eval > val)
+#if GLIB_CHECK_VERSION(2,31,7)
+				g_value_set_schar (cdata->data_value, val);
+#else
 				g_value_set_char (cdata->data_value, val);
+#endif
 			break;
 		case GDA_DATA_PIVOT_MAX:
 			if (eval < val)
+#if GLIB_CHECK_VERSION(2,31,7)
+				g_value_set_schar (cdata->data_value, val);
+#else
 				g_value_set_char (cdata->data_value, val);
+#endif
 			break;
 		case GDA_DATA_PIVOT_SUM: {
 			gint tmp;
@@ -883,7 +905,11 @@ aggregate_handle_char (CellData *cdata, gchar val)
 					     GDA_DATA_PIVOT_ERROR, GDA_DATA_PIVOT_OVERFLOW_ERROR,
 					     "%s", _("Integer overflow"));
 			else
+#if GLIB_CHECK_VERSION(2,31,7)
+				g_value_set_schar (cdata->data_value, (gint8) tmp);
+#else
 				g_value_set_char (cdata->data_value, (gchar) tmp);
+#endif
 			break;
 		}
 		case GDA_DATA_PIVOT_AVG: {
@@ -909,7 +935,11 @@ aggregate_handle_char (CellData *cdata, gchar val)
 		case GDA_DATA_PIVOT_MAX:
 		case GDA_DATA_PIVOT_SUM:
 			cdata->data_value = gda_value_new (G_TYPE_CHAR);
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_value_set_schar (cdata->data_value, val);
+#else
 			g_value_set_char (cdata->data_value, val);
+#endif
 			break;
 		case GDA_DATA_PIVOT_AVG:
 			cdata->data_value = gda_value_new (G_TYPE_INT64);
@@ -1166,7 +1196,11 @@ aggregate_handle_new_value (CellData *cdata, const GValue *new_value)
 	else if (cdata->gtype == G_TYPE_DOUBLE)
 		return aggregate_handle_double (cdata, g_value_get_double (new_value));
 	else if (cdata->gtype == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+		return aggregate_handle_char (cdata, g_value_get_schar (new_value));
+#else
 		return aggregate_handle_char (cdata, g_value_get_char (new_value));
+#endif
 	else if (cdata->gtype == G_TYPE_UCHAR)
 		return aggregate_handle_uchar (cdata, g_value_get_uchar (new_value));
 	else if (cdata->gtype == GDA_TYPE_SHORT)
diff --git a/libgda/gda-holder.c b/libgda/gda-holder.c
index ecedf45..6e01209 100644
--- a/libgda/gda-holder.c
+++ b/libgda/gda-holder.c
@@ -497,7 +497,11 @@ gda_holder_new_inline (GType type, const gchar *id, ...)
 		else if (type == GDA_TYPE_USHORT)
 			gda_value_set_ushort (value, va_arg (ap, guint));
 		else if (type == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_value_set_schar (value, va_arg (ap, int));
+#else
 			g_value_set_char (value, va_arg (ap, int));
+#endif
 		else if (type == G_TYPE_UCHAR)
 			g_value_set_uchar (value, va_arg (ap, guint));
 		else if (type == G_TYPE_FLOAT)
diff --git a/libgda/gda-init.c b/libgda/gda-init.c
index 560f035..ba4dafd 100644
--- a/libgda/gda-init.c
+++ b/libgda/gda-init.c
@@ -141,6 +141,9 @@ gda_init (void)
 	g_free (file);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	/* threading cannot ne disabled */
+#else
 	/* Threading support if possible */
 	if (!getenv ("LIBGDA_NO_THREADS")) { /* Flawfinder: ignore */
 #ifdef G_THREADS_ENABLED
@@ -150,6 +153,7 @@ gda_init (void)
 #endif
 #endif
 	}
+#endif
 
 	g_type_init ();
 
diff --git a/libgda/gda-lockable.c b/libgda/gda-lockable.c
index 77827a5..819e240 100644
--- a/libgda/gda-lockable.c
+++ b/libgda/gda-lockable.c
@@ -20,7 +20,15 @@
 
 #include <libgda/gda-lockable.h>
 
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex init_rmutex;
+#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
+#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
+#else
 static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+#define MUTEX_LOCK() g_static_rec_mutex_lock(&init_mutex)
+#define MUTEX_UNLOCK() g_static_rec_mutex_unlock(&init_mutex)
+#endif
 static void gda_lockable_class_init (gpointer g_class);
 
 GType
@@ -42,12 +50,12 @@ gda_lockable_get_type (void)
 			0
 		};
 		
-		g_static_rec_mutex_lock (&init_mutex);
+		MUTEX_LOCK();
 		if (type == 0) {
 			type = g_type_register_static (G_TYPE_INTERFACE, "GdaLockable", &info, 0);
 			g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
 		}
-		g_static_rec_mutex_unlock (&init_mutex);
+		MUTEX_UNLOCK();
 	}
 	return type;
 }
@@ -57,11 +65,11 @@ gda_lockable_class_init (G_GNUC_UNUSED gpointer g_class)
 {
 	static gboolean initialized = FALSE;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	if (! initialized) {
 		initialized = TRUE;
 	}
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 }
 
 /**
diff --git a/libgda/gda-log.c b/libgda/gda-log.c
index 0b78371..73c4423 100644
--- a/libgda/gda-log.c
+++ b/libgda/gda-log.c
@@ -36,9 +36,15 @@
 #include <glib/gi18n-lib.h>
 #include <libgda/gda-log.h>
 
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex gda_rmutex;
+#define GDA_LOG_LOCK() g_rec_mutex_lock(&gda_rmutex)
+#define GDA_LOG_UNLOCK() g_rec_mutex_unlock(&gda_rmutex)
+#else
 static GStaticRecMutex gda_mutex = G_STATIC_REC_MUTEX_INIT;
 #define GDA_LOG_LOCK() g_static_rec_mutex_lock(&gda_mutex)
 #define GDA_LOG_UNLOCK() g_static_rec_mutex_unlock(&gda_mutex)
+#endif
 static gboolean log_enabled = TRUE;
 static gboolean log_opened = FALSE;
 
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index b3e7eda..621e8ec 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -87,7 +87,15 @@ static void gda_meta_store_get_property (GObject *object,
 static gboolean initialize_cnc_struct (GdaMetaStore *store, GError **error);
 static void gda_meta_store_change_free (GdaMetaStoreChange *change);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex init_rmutex;
+#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
+#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
+#else
 static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+#define MUTEX_LOCK() g_static_rec_mutex_lock(&init_mutex)
+#define MUTEX_UNLOCK() g_static_rec_mutex_unlock(&init_mutex)
+#endif
 
 /* simple predefined statements */
 enum {
@@ -306,10 +314,10 @@ gda_meta_store_get_type (void) {
 			0
 		};
 
-		g_static_rec_mutex_lock (&init_mutex);
+		MUTEX_LOCK();
 		if (type == 0)
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaMetaStore", &info, 0);
-		g_static_rec_mutex_unlock (&init_mutex);
+		MUTEX_UNLOCK();
 	}
 	return type;
 }
@@ -373,7 +381,7 @@ gda_meta_store_class_init (GdaMetaStoreClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	parent_class = g_type_class_peek_parent (klass);
 
 	/**
@@ -521,7 +529,7 @@ gda_meta_store_class_init (GdaMetaStoreClass *klass)
 	g_string_free (string, TRUE);
 #endif
 
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 }
 
 
@@ -562,7 +570,7 @@ gda_meta_store_constructor (GType type,
 	GdaMetaStore *store;
 	gboolean been_specified = FALSE;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	object = G_OBJECT_CLASS (parent_class)->constructor (type,
 		n_construct_properties,
 		construct_properties);
@@ -608,7 +616,7 @@ gda_meta_store_constructor (GType type,
 		else
 			create_db_objects (klass, store);
 	}
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 
 	return object;
 }
@@ -657,12 +665,12 @@ gda_meta_store_new (const gchar *cnc_string)
 	GObject *obj;
 	GdaMetaStore *store;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	if (cnc_string)
 		obj = g_object_new (GDA_TYPE_META_STORE, "cnc-string", cnc_string, NULL);
 	else
 		obj = g_object_new (GDA_TYPE_META_STORE, "cnc-string", "SQLite://DB_NAME=__gda_tmp", NULL);
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 	store = GDA_META_STORE (obj);
 	if (!store->priv->cnc) {
 		g_object_unref (store);
diff --git a/libgda/gda-mutex.c b/libgda/gda-mutex.c
index 2bacae6..54dbabb 100644
--- a/libgda/gda-mutex.c
+++ b/libgda/gda-mutex.c
@@ -20,6 +20,116 @@
 
 #include <libgda/gda-mutex.h>
 
+#if GLIB_CHECK_VERSION(2,31,7)
+
+/**
+ * gda_mutex_new: (skip)
+ *
+ * Creates a new #GdaMutex.
+ *
+ * Deprecated: 5.2.0: use #GRecMutex instead.
+ *
+ * Returns: (transfer full): a new #GdaMutex
+ */
+GdaMutex*
+gda_mutex_new (void)
+{
+	GdaMutex *mutex;
+	mutex = g_new0 (GdaMutex, 1);
+	g_rec_mutex_init (mutex);
+	return mutex;
+}
+
+/**
+ * gda_mutex_lock:
+ * @mutex: a #GdaMutex
+ *
+ * Locks @mutex. If @mutex is already locked by another thread, the current thread will block until @mutex is unlocked by the other thread.
+ *
+ * This function can be used even if g_thread_init() has not yet been called, and, in that case, will do nothing.
+ *
+ * Note: unlike g_mutex_lock(), the #GdaMutex is recursive, which means a thread can lock it several times (and has
+ * to unlock it as many times to actually unlock it).
+ *
+ * Deprecated: 5.2.0: use #GRecMutex instead.
+ */
+void
+gda_mutex_lock (GdaMutex *mutex)
+{
+	g_rec_mutex_lock (mutex);
+}
+
+/**
+ * gda_mutex_trylock:
+ * @mutex: a #GdaMutex
+ * 
+ * Tries to lock @mutex. If @mutex is already locked by another thread, it immediately returns FALSE.
+ * Otherwise it locks @mutex and returns TRUE
+ *
+ * This function can be used even if g_thread_init() has not yet been called, and, in that case, will immediately return TRUE.
+ *
+ * Note: Unlike g_mutex_trylock(), the #GdaMutex is recursive, which means a thread can lock it several times (and has
+ * to unlock it as many times to actually unlock it)
+ *
+ * Returns: TRUE, if @mutex could be locked.
+ *
+ * Deprecated: 5.2.0: use #GRecMutex instead.
+ */
+gboolean
+gda_mutex_trylock (GdaMutex *mutex)
+{
+	return g_rec_mutex_trylock (mutex);
+}
+
+/**
+ * gda_mutex_unlock:
+ * @mutex: a #GdaMutex
+ *
+ * Unlocks @mutex. If another thread is blocked in a gda_mutex_lock() call for @mutex, it wil
+ * be woken and can lock @mutex itself.
+ * This function can be used even if g_thread_init() has not yet been called, and, in that case, will do nothing. 
+ *
+ * Deprecated: 5.2.0: use #GRecMutex instead.
+ */
+void
+gda_mutex_unlock (GdaMutex *mutex)
+{
+	g_rec_mutex_unlock (mutex);
+}
+
+/**
+ * gda_mutex_free:
+ * @mutex: (transfer full): a #GdaMutex
+ *
+ * Destroys @mutex.
+ *
+ * Deprecated: 5.2.0: use #GRecMutex instead.
+ */
+void
+gda_mutex_free (GdaMutex *mutex)
+{
+	g_rec_mutex_clear (mutex);
+	g_free (mutex);
+}
+
+#ifdef GDA_DEBUG_MUTEX
+void
+gda_mutex_debug (GdaMutex *mutex, gboolean debug)
+{
+	g_warning ("Nothing to debug, GdaMutex is a GRecMutex.");
+}
+
+void
+gda_mutex_dump_usage (GdaMutex *mutex, FILE *stream)
+{
+	g_warning ("Nothing to debug, GdaMutex is a GRecMutex.");
+	g_fprintf (stream, "%s", "Nothing to debug, GdaMutex is a GRecMutex.");
+}
+#endif
+
+
+#else /* GLIB_CHECK_VERSION */
+
 #ifdef GDA_DEBUG_MUTEX
 #define FRAMES_SIZE 10
 #include <glib/gprintf.h>
@@ -403,3 +513,5 @@ gda_mutex_free (GdaMutex *mutex)
 #endif
 	g_free (mutex);
 }
+
+#endif /* GLIB_CHECK_VERSION */
diff --git a/libgda/gda-mutex.h b/libgda/gda-mutex.h
index bc66479..5659060 100644
--- a/libgda/gda-mutex.h
+++ b/libgda/gda-mutex.h
@@ -28,7 +28,11 @@
 
 G_BEGIN_DECLS
 
+#if GLIB_CHECK_VERSION(2,31,7)
+typedef GRecMutex GdaMutex;
+#else
 typedef struct _GdaMutex GdaMutex;
+#endif
 
 /**
  * SECTION:gda-mutex
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 58fb091..4969773 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -533,7 +533,11 @@ gda_set_new_inline (gint nb, ...)
 		else if (type == GDA_TYPE_USHORT)
 			gda_value_set_ushort (value, va_arg (ap, guint));
 		else if (type == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_value_set_schar (value, va_arg (ap, gint));
+#else
 			g_value_set_char (value, va_arg (ap, int));
+#endif
 		else if (type == G_TYPE_UCHAR)
 			g_value_set_uchar (value, va_arg (ap, guint));
 		else if (type == G_TYPE_FLOAT)
@@ -637,7 +641,11 @@ gda_set_set_holder_value (GdaSet *set, GError **error, const gchar *holder_id, .
 	else if (type == GDA_TYPE_USHORT)
 		gda_value_set_ushort (value, va_arg (ap, guint));
 	else if (type == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_value_set_schar (value, va_arg (ap, gint));
+#else
 		g_value_set_char (value, va_arg (ap, int));
+#endif
 	else if (type == G_TYPE_UCHAR)
 		g_value_set_uchar (value, va_arg (ap, guint));
 	else if (type == G_TYPE_FLOAT)
diff --git a/libgda/gda-sql-builder.c b/libgda/gda-sql-builder.c
index 9b83442..10453b5 100644
--- a/libgda/gda-sql-builder.c
+++ b/libgda/gda-sql-builder.c
@@ -48,8 +48,6 @@ static void gda_sql_builder_get_property (GObject *object,
 					 GValue *value,
 					 GParamSpec *pspec);
 
-static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
-
 
 typedef struct {
 	GdaSqlAnyPart *part;
@@ -84,6 +82,7 @@ gda_sql_builder_get_type (void) {
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaSqlBuilderClass),
 			(GBaseInitFunc) NULL,
@@ -97,10 +96,10 @@ gda_sql_builder_get_type (void) {
 			0
 		};
 
-		g_static_rec_mutex_lock (&init_mutex);
+		g_static_mutex_lock (&registering);
 		if (type == 0)
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaSqlBuilder", &info, 0);
-		g_static_rec_mutex_unlock (&init_mutex);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }
@@ -552,7 +551,11 @@ create_typed_value (GType type, va_list *ap)
 	else if (type == GDA_TYPE_USHORT)
 		gda_value_set_ushort ((v = gda_value_new (GDA_TYPE_USHORT)), va_arg (*ap, guint));
 	else if (type == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_value_set_schar ((v = gda_value_new (G_TYPE_CHAR)), va_arg (*ap, gint));
+#else
 		g_value_set_char ((v = gda_value_new (G_TYPE_CHAR)), va_arg (*ap, gint));
+#endif
 	else if (type == G_TYPE_UCHAR)
 		g_value_set_uchar ((v = gda_value_new (G_TYPE_UCHAR)), va_arg (*ap, guint));
 	else if (type == G_TYPE_FLOAT)
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index a65cb18..a82b5a0 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -169,7 +169,11 @@ set_from_string (GValue *value, const gchar *as_string)
 	else if (type == G_TYPE_CHAR) {
 		lvalue = strtol (as_string, endptr, 10);
 		if (*as_string!=0 && **endptr==0) {
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_value_set_schar(value,(gint)lvalue);
+#else
 			g_value_set_char(value,(gchar)lvalue);
+#endif
 			retval = TRUE;
 		}
 	}
@@ -2573,8 +2577,13 @@ gda_value_compare (const GValue *value1, const GValue *value2)
 	}
 
 	else if (type == G_TYPE_CHAR) {
+#if GLIB_CHECK_VERSION(2,31,7)
+		gint8 c1 = g_value_get_schar (value1);
+		gint8 c2 = g_value_get_schar (value2);
+#else
 		gchar c1 = g_value_get_char (value1);
 		gchar c2 = g_value_get_char (value2);
+#endif
 		return (c1 > c2) ? 1 : ((c1 == c2) ? 0 : -1);
 	}
 
diff --git a/libgda/handlers/gda-handler-numerical.c b/libgda/handlers/gda-handler-numerical.c
index aaba305..798a4ea 100644
--- a/libgda/handlers/gda-handler-numerical.c
+++ b/libgda/handlers/gda-handler-numerical.c
@@ -314,7 +314,11 @@ gda_handler_numerical_get_value_from_str (GdaDataHandler *iface, const gchar *st
 	else if (type == G_TYPE_CHAR) {
 		if (!*endptr && (llint >= G_MININT8) && (llint <= G_MAXINT8)) {
 			value = g_value_init (g_new0 (GValue, 1), G_TYPE_CHAR);
-			g_value_set_char (value, (gchar) llint);
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_value_set_schar (value, (gchar) llint);
+#else
+			g_value_set_char (value, (gint8) llint);
+#endif
 		}
 	}
 	else if (type == G_TYPE_UINT64) {
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index c091241..7a68fd8 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -66,7 +66,6 @@
 #define _GDA_PSTMT(x) ((GdaPStmt*)(x))
 
 #define FILE_EXTENSION ".db"
-static GStaticRecMutex cnc_mutex = G_STATIC_REC_MUTEX_INIT;
 static gchar *get_table_nth_column_name (GdaConnection *cnc, const gchar *table_name, gint pos);
 
 /* TMP */
@@ -727,6 +726,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 	gint errmsg;
 	SqliteConnectionData *cdata;
 	gchar *dup = NULL;
+	static GStaticMutex cnc_mutex = G_STATIC_MUTEX_INIT;
 #ifdef SQLITE_HAS_CODEC
 	const gchar *passphrase = NULL;
 #endif
@@ -739,7 +739,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
                 return FALSE;
 	}
 
-	g_static_rec_mutex_lock (&cnc_mutex);
+	g_static_mutex_lock (&cnc_mutex);
 
 	/* get all parameters received */
 	dirname = gda_quark_list_find (params, "DB_DIR");
@@ -764,7 +764,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 			if (!str) {
 				gda_connection_add_event_string (cnc,
 								 _("The connection string must contain DB_DIR and DB_NAME values"));
-				g_static_rec_mutex_unlock (&cnc_mutex);
+				g_static_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 			else {
@@ -794,7 +794,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 									   "DB_DIR (the path to the database file) and DB_NAME "
 									   "(the database file without the '%s' at the end)."), FILE_EXTENSION);
 					g_free (dup);
-					g_static_rec_mutex_unlock (&cnc_mutex);
+					g_static_mutex_unlock (&cnc_mutex);
 					return FALSE;
 				}
 				else
@@ -816,7 +816,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 								 _("The DB_DIR part of the connection string must point "
 								   "to a valid directory"));
 				g_free (dup);
-				g_static_rec_mutex_unlock (&cnc_mutex);
+				g_static_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 
@@ -857,7 +857,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 		gda_connection_add_event_string (cnc, SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
 		gda_sqlite_free_cnc_data (cdata);
 
-		g_static_rec_mutex_unlock (&cnc_mutex);
+		g_static_mutex_unlock (&cnc_mutex);
 		return FALSE;
 	}
 
@@ -873,7 +873,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 		if (errmsg != SQLITE_OK) {
 			gda_connection_add_event_string (cnc, _("Wrong encryption passphrase"));
 			gda_sqlite_free_cnc_data (cdata);
-			g_static_rec_mutex_unlock (&cnc_mutex);
+			g_static_mutex_unlock (&cnc_mutex);
 			return FALSE;
 		}
 	}
@@ -894,7 +894,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 		else {
 			gda_connection_add_event_string (cnc, _("Extension loading is not supported"));
 			gda_sqlite_free_cnc_data (cdata);
-			g_static_rec_mutex_unlock (&cnc_mutex);
+			g_static_mutex_unlock (&cnc_mutex);
 			return FALSE;
 		}
 	}
@@ -940,7 +940,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 			SQLITE3_CALL (sqlite3_free) (errmsg);
 			gda_sqlite_free_cnc_data (cdata);
 			gda_connection_internal_set_provider_data (cnc, NULL, (GDestroyNotify) gda_sqlite_free_cnc_data);
-			g_static_rec_mutex_unlock (&cnc_mutex);
+			g_static_mutex_unlock (&cnc_mutex);
 			return FALSE;
 		}
 	}
@@ -965,7 +965,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 			gda_sqlite_free_cnc_data (cdata);
 			gda_connection_internal_set_provider_data (cnc, NULL,
 							(GDestroyNotify) gda_sqlite_free_cnc_data);
-			g_static_rec_mutex_unlock (&cnc_mutex);
+			g_static_mutex_unlock (&cnc_mutex);
 			return FALSE;
 		}
 	}
@@ -978,7 +978,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 				gda_sqlite_free_cnc_data (cdata);
 				gda_connection_internal_set_provider_data (cnc, NULL,
 							(GDestroyNotify) gda_sqlite_free_cnc_data);
-				g_static_rec_mutex_unlock (&cnc_mutex);
+				g_static_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 		}
@@ -1006,7 +1006,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 								 func->name);
 				gda_sqlite_free_cnc_data (cdata);
 				gda_connection_internal_set_provider_data (cnc, NULL, (GDestroyNotify) gda_sqlite_free_cnc_data);
-				g_static_rec_mutex_unlock (&cnc_mutex);
+				g_static_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 		}
@@ -1026,7 +1026,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 								 func->name);
 				gda_sqlite_free_cnc_data (cdata);
 				gda_connection_internal_set_provider_data (cnc, NULL, (GDestroyNotify) gda_sqlite_free_cnc_data);
-				g_static_rec_mutex_unlock (&cnc_mutex);
+				g_static_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 		}
@@ -1045,7 +1045,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 								 func->name);
 				gda_sqlite_free_cnc_data (cdata);
 				gda_connection_internal_set_provider_data (cnc, NULL, (GDestroyNotify) gda_sqlite_free_cnc_data);
-				g_static_rec_mutex_unlock (&cnc_mutex);
+				g_static_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 		}
@@ -1056,7 +1056,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 	else
 		g_object_set (G_OBJECT (cnc), "thread-owner", g_thread_self (), NULL);
 
-	g_static_rec_mutex_unlock (&cnc_mutex);
+	g_static_mutex_unlock (&cnc_mutex);
 	return TRUE;
 }
 
@@ -3180,7 +3180,11 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_USHORT)
 			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, gda_value_get_ushort (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_CHAR)
+#if GLIB_CHECK_VERSION(2,31,7)
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_schar (value));
+#else
 			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_char (value));
+#endif
 		else if (G_VALUE_TYPE (value) == G_TYPE_UCHAR)
 			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_uchar (value));
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
diff --git a/libgda/sqlite/gda-sqlite-recordset.c b/libgda/sqlite/gda-sqlite-recordset.c
index 3a5b99a..95fed5c 100644
--- a/libgda/sqlite/gda-sqlite-recordset.c
+++ b/libgda/sqlite/gda-sqlite-recordset.c
@@ -553,7 +553,11 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 						gda_row_invalidate_value_e (prow, value, lerror);
 					}
 					else
+#if GLIB_CHECK_VERSION(2,31,7)
+						g_value_set_schar (value, (gchar) i);
+#else
 						g_value_set_char (value, (gchar) i);
+#endif
 				}
 				else if (type == G_TYPE_UCHAR) {
 					gint64 i;
diff --git a/libgda/thread-wrapper/gda-thread-wrapper.c b/libgda/thread-wrapper/gda-thread-wrapper.c
index 9b5b170..2a291a4 100644
--- a/libgda/thread-wrapper/gda-thread-wrapper.c
+++ b/libgda/thread-wrapper/gda-thread-wrapper.c
@@ -40,7 +40,7 @@
  * by the worker thread. It is used to avoid creating signal data for threads for which
  * no job is being performed 
  */
-GStaticPrivate worker_thread_current_queue = G_STATIC_PRIVATE_INIT;
+GPrivate worker_thread_current_queue;
 
 typedef struct _ThreadData ThreadData;
 typedef struct _Job Job;
@@ -48,7 +48,11 @@ typedef struct _SignalSpec SignalSpec;
 typedef struct _Pipe Pipe;
 
 struct _GdaThreadWrapperPrivate {
+#if GLIB_CHECK_VERSION(2,31,7)
+	GRecMutex    rmutex;
+#else
 	GdaMutex    *mutex;
+#endif
 	guint        next_job_id;
 	GThread     *worker_thread;
 	GAsyncQueue *to_worker_thread;
@@ -68,12 +72,21 @@ struct _Pipe {
 	int          fds[2]; /* [0] for reading and [1] for writing */
 	GIOChannel  *ioc;
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	GMutex       mutex;
+#else
 	GMutex      *mutex; /* locks @ref_count */
+#endif
 	guint        ref_count;
 };
 
+#if GLIB_CHECK_VERSION(2,31,7)
+#define pipe_lock(x) g_mutex_lock(& (((Pipe*)x)->mutex))
+#define pipe_unlock(x) g_mutex_unlock(& (((Pipe*)x)->mutex))
+#else
 #define pipe_lock(x) g_mutex_lock(((Pipe*)x)->mutex);
 #define pipe_unlock(x) g_mutex_unlock(((Pipe*)x)->mutex);
+#endif
 
 static Pipe *
 pipe_ref (Pipe *p)
@@ -100,7 +113,7 @@ pipe_unref (Pipe *p)
 #endif
 		if (p->ref_count == 0) {
 			/* destroy @p */
-			GMutex *m = p->mutex;
+			GMutex *m = &(p->mutex);
 
 			if (p->ioc)
 				g_io_channel_unref (p->ioc);
@@ -122,7 +135,11 @@ pipe_unref (Pipe *p)
 			g_free (p);
 
 			g_mutex_unlock (m);
+#if GLIB_CHECK_VERSION(2,31,7)
+			g_mutex_clear (m);
+#else
 			g_mutex_free (m);
+#endif
 
 		}
 		else
@@ -139,7 +156,11 @@ pipe_new (void)
 	Pipe *p;
 
 	p = g_new0 (Pipe, 1);
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_init (&(p->mutex));
+#else
 	p->mutex = g_mutex_new ();
+#endif
 	p->ref_count = 1;
 	p->thread = g_thread_self ();
 #ifdef G_OS_WIN32
@@ -175,10 +196,18 @@ static Pipe *
 get_pipe (GdaThreadWrapper *wrapper, GThread *thread)
 {
 	Pipe *p = NULL;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	if (wrapper->priv->pipes_hash)
 		p = g_hash_table_lookup (wrapper->priv->pipes_hash, thread);
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	return p;
 }
 
@@ -275,12 +304,21 @@ struct _SignalSpec {
         GdaThreadWrapperCallback callback;
         gpointer                 data;
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	GMutex        mutex;
+#else
 	GMutex       *mutex;
+#endif
 	guint         ref_count;
 };
 
+#if GLIB_CHECK_VERSION(2,31,7)
+#define signal_spec_lock(x) g_mutex_lock(& (((SignalSpec*)x)->mutex))
+#define signal_spec_unlock(x) g_mutex_unlock(& (((SignalSpec*)x)->mutex))
+#else
 #define signal_spec_lock(x) g_mutex_lock(((SignalSpec*)x)->mutex);
 #define signal_spec_unlock(x) g_mutex_unlock(((SignalSpec*)x)->mutex);
+#endif
 
 /*
  * call signal_spec_lock() before calling this function
@@ -291,7 +329,11 @@ signal_spec_unref (SignalSpec *sigspec)
 	sigspec->ref_count --;
 	if (sigspec->ref_count == 0) {
 		signal_spec_unlock (sigspec);
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_mutex_clear (&(sigspec->mutex));
+#else
 		g_mutex_free (sigspec->mutex);
+#endif
 		if (sigspec->instance && (sigspec->signal_id > 0))
 			g_signal_handler_disconnect (sigspec->instance, sigspec->signal_id);
 		if (sigspec->reply_queue)
@@ -334,8 +376,11 @@ static ThreadData *
 get_thread_data (GdaThreadWrapper *wrapper, GThread *thread)
 {
 	ThreadData *td;
-
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, thread);
 	if (!td) {
 		Pipe *p;
@@ -349,7 +394,11 @@ get_thread_data (GdaThreadWrapper *wrapper, GThread *thread)
 		td->notif = pipe_ref (p);
 		g_hash_table_insert (wrapper->priv->threads_hash, thread, td);
 	}
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	return td;
 }
 
@@ -525,11 +574,19 @@ worker_thread_entry_point (GAsyncQueue *to_worker_thread)
 		Job *job;
 		
 		/* pop next job and mark it as being processed */
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_private_set (&worker_thread_current_queue, NULL);
+#else
 		g_static_private_set (&worker_thread_current_queue, NULL, NULL);
+#endif
 		g_async_queue_lock (in);
 		job = g_async_queue_pop_unlocked (in);
 		job->processed = TRUE;
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_private_set (&worker_thread_current_queue, job->reply_queue);
+#else
 		g_static_private_set (&worker_thread_current_queue, job->reply_queue, NULL);
+#endif
 		g_async_queue_unlock (in);
 
 		if (job->cancelled) {
@@ -579,15 +636,25 @@ gda_thread_wrapper_init (GdaThreadWrapper *wrapper, G_GNUC_UNUSED GdaThreadWrapp
 	g_return_if_fail (GDA_IS_THREAD_WRAPPER (wrapper));
 
 	wrapper->priv = g_new0 (GdaThreadWrapperPrivate, 1);
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_init (&(wrapper->priv->rmutex));
+#else
 	wrapper->priv->mutex = gda_mutex_new ();
+#endif
 	wrapper->priv->next_job_id = 1;
 
 	wrapper->priv->threads_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) thread_data_free);
 
 	wrapper->priv->to_worker_thread = g_async_queue_new ();
+#if GLIB_CHECK_VERSION(2,31,7)
+	wrapper->priv->worker_thread = g_thread_new ("worker",
+						     (GThreadFunc) worker_thread_entry_point,
+						     g_async_queue_ref (wrapper->priv->to_worker_thread)); /* inc. ref for sub thread usage */
+#else
 	wrapper->priv->worker_thread = g_thread_create ((GThreadFunc) worker_thread_entry_point,
-						     g_async_queue_ref (wrapper->priv->to_worker_thread), /* inc. ref for sub thread usage */
-						     FALSE, NULL);
+							g_async_queue_ref (wrapper->priv->to_worker_thread), /* inc. ref for sub thread usage */
+							FALSE, NULL);
+#endif
 	
 	wrapper->priv->pipes_hash = NULL;
 
@@ -653,7 +720,11 @@ gda_thread_wrapper_dispose (GObject *object)
 		g_async_queue_unref (wrapper->priv->to_worker_thread);
 		wrapper->priv->worker_thread = NULL; /* side note: don't wait for sub thread to terminate */
 
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_clear (&(wrapper->priv->rmutex));
+#else
 		gda_mutex_free (wrapper->priv->mutex);
+#endif
 
 		if (wrapper->priv->pipes_hash)
 			g_hash_table_destroy (wrapper->priv->pipes_hash);
@@ -800,7 +871,11 @@ gda_thread_wrapper_get_io_channel (GdaThreadWrapper *wrapper)
 	g_return_val_if_fail (wrapper->priv, NULL);
 
 	th = g_thread_self ();
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	p = get_pipe (wrapper, th);
 	if (!p) {
 		p = pipe_new ();
@@ -813,7 +888,11 @@ gda_thread_wrapper_get_io_channel (GdaThreadWrapper *wrapper)
 			g_hash_table_insert (wrapper->priv->pipes_hash, th, p);
 		}
 	}
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	if (p)
 		return p->ioc;
 	else
@@ -837,7 +916,11 @@ gda_thread_wrapper_unset_io_channel (GdaThreadWrapper *wrapper)
 	g_return_if_fail (GDA_IS_THREAD_WRAPPER (wrapper));
 	g_return_if_fail (wrapper->priv);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	th = g_thread_self ();
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, th);
 	if (td) {
@@ -846,7 +929,11 @@ gda_thread_wrapper_unset_io_channel (GdaThreadWrapper *wrapper)
 		if (p)
 			clean_notifications (wrapper, td);
 	}
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 }
 
 /**
@@ -890,9 +977,17 @@ gda_thread_wrapper_execute (GdaThreadWrapper *wrapper, GdaThreadWrapperFunc func
 	job->type = JOB_TYPE_EXECUTE;
 	job->processed = FALSE;
 	job->cancelled = FALSE;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	job->job_id = wrapper->priv->next_job_id++;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	job->func = func;
 	job->void_func = NULL;
 	job->arg = arg;
@@ -972,9 +1067,17 @@ gda_thread_wrapper_execute_void (GdaThreadWrapper *wrapper, GdaThreadWrapperVoid
 	job->type = JOB_TYPE_EXECUTE;
 	job->processed = FALSE;
 	job->cancelled = FALSE;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	job->job_id = wrapper->priv->next_job_id++;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	job->func = NULL;
 	job->void_func = func;
 	job->arg = arg;
@@ -1035,13 +1138,21 @@ gda_thread_wrapper_cancel (GdaThreadWrapper *wrapper, guint id)
 	ThreadData *td;
 
 	g_return_val_if_fail (GDA_IS_THREAD_WRAPPER (wrapper), FALSE);
-	
+
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, g_thread_self());
 	if (!td) {
 		/* nothing to be done for this thread */
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 		gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 		return FALSE;
 	}
 
@@ -1065,7 +1176,11 @@ gda_thread_wrapper_cancel (GdaThreadWrapper *wrapper, guint id)
 		}
 	}
 	g_async_queue_unlock (wrapper->priv->to_worker_thread);
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 
 	return retval;
 }
@@ -1097,9 +1212,17 @@ gda_thread_wrapper_iterate (GdaThreadWrapper *wrapper, gboolean may_block)
 	g_return_if_fail (GDA_IS_THREAD_WRAPPER (wrapper));
 	g_return_if_fail (wrapper->priv);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, g_thread_self());
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	if (!td) {
 		/* nothing to be done for this thread */
 		return;
@@ -1181,9 +1304,17 @@ gda_thread_wrapper_fetch_result (GdaThreadWrapper *wrapper, gboolean may_lock, g
 	g_return_val_if_fail (wrapper->priv, NULL);
 	g_return_val_if_fail (exp_id > 0, NULL);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, g_thread_self());
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	if (!td) {
 		/* nothing to be done for this thread */
 		return NULL;
@@ -1203,9 +1334,17 @@ gda_thread_wrapper_fetch_result (GdaThreadWrapper *wrapper, gboolean may_lock, g
 					    (g_async_queue_length (td->from_worker_thread) == 0) &&
 					    !td->signals_list) {
 						/* remove this ThreadData */
+#if GLIB_CHECK_VERSION(2,31,7)
+						g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 						gda_mutex_lock (wrapper->priv->mutex);
+#endif
 						g_hash_table_remove (wrapper->priv->threads_hash, g_thread_self());
+#if GLIB_CHECK_VERSION(2,31,7)
+						g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 						gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 					}
 					goto out;
 				}
@@ -1261,11 +1400,19 @@ gda_thread_wrapper_get_waiting_size (GdaThreadWrapper *wrapper)
 	g_return_val_if_fail (GDA_IS_THREAD_WRAPPER (wrapper), 0);
 	g_return_val_if_fail (wrapper->priv, 0);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, g_thread_self());
 	if (!td) {
 		/* nothing to be done for this thread */
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 		gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 		return 0;
 	}
 	
@@ -1276,7 +1423,11 @@ gda_thread_wrapper_get_waiting_size (GdaThreadWrapper *wrapper)
 			size++;
 	}
 	g_async_queue_unlock (wrapper->priv->to_worker_thread);
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 	return size;
 }
 
@@ -1299,9 +1450,15 @@ worker_thread_closure_marshal (GClosure *closure,
 		return;
 
 	/* check that the worker thread is working on a job for which job->reply_queue == sigspec->reply_queue */
+#if GLIB_CHECK_VERSION(2,31,7)
+	if (sigspec->private &&
+	    g_private_get (&worker_thread_current_queue) != sigspec->reply_queue)
+		return;
+#else
 	if (sigspec->private &&
 	    g_static_private_get (&worker_thread_current_queue) != sigspec->reply_queue)
 		return;
+#endif
 
 	gsize i;
 	/*
@@ -1437,7 +1594,11 @@ gda_thread_wrapper_connect_raw (GdaThreadWrapper *wrapper,
 	g_return_val_if_fail (GDA_IS_THREAD_WRAPPER (wrapper), 0);
 	g_return_val_if_fail (wrapper->priv, 0);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 	
 	td = get_thread_data (wrapper, g_thread_self());
 
@@ -1463,7 +1624,11 @@ gda_thread_wrapper_connect_raw (GdaThreadWrapper *wrapper,
         sigspec->instance = instance;
         sigspec->callback = callback;
         sigspec->data = data;
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_init (&(sigspec->mutex));
+#else
 	sigspec->mutex = g_mutex_new ();
+#endif
 	sigspec->ref_count = 1;
 
 	GClosure *cl;
@@ -1476,7 +1641,11 @@ gda_thread_wrapper_connect_raw (GdaThreadWrapper *wrapper,
 
 	td->signals_list = g_slist_append (td->signals_list, sigspec);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 
 	return sigspec->signal_id;
 }
@@ -1517,7 +1686,11 @@ gda_thread_wrapper_disconnect (GdaThreadWrapper *wrapper, gulong id)
 	g_return_if_fail (GDA_IS_THREAD_WRAPPER (wrapper));
 	g_return_if_fail (wrapper->priv);
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 
 	td = g_hash_table_lookup (wrapper->priv->threads_hash, g_thread_self());
 	if (!td) {
@@ -1527,7 +1700,11 @@ gda_thread_wrapper_disconnect (GdaThreadWrapper *wrapper, gulong id)
 	}
 	if (!td) {
 		g_warning (_("Signal %lu does not exist"), id);
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 		gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 		return;
 	}
 
@@ -1540,7 +1717,11 @@ gda_thread_wrapper_disconnect (GdaThreadWrapper *wrapper, gulong id)
 
 	if (!sigspec) {
 		g_warning (_("Signal does not exist\n"));
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 		gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 		return;
 	}
 
@@ -1565,8 +1746,11 @@ gda_thread_wrapper_disconnect (GdaThreadWrapper *wrapper, gulong id)
 		/* remove this ThreadData */
 		g_hash_table_remove (wrapper->priv->threads_hash, g_thread_self());
 	}
-
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 }
 
 /**
@@ -1589,19 +1773,33 @@ gda_thread_wrapper_steal_signal (GdaThreadWrapper *wrapper, gulong id)
         g_return_if_fail (wrapper->priv);
 	g_return_if_fail (id > 0);
 
-        gda_mutex_lock (wrapper->priv->mutex);
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_lock (&(wrapper->priv->rmutex));
+#else
+	gda_mutex_lock (wrapper->priv->mutex);
+#endif
 
 	gulong theid = id;
 	old_td = g_hash_table_find (wrapper->priv->threads_hash,
 				    (GHRFunc) find_signal_r_func, &theid);
 	if (!old_td) {
 		g_warning (_("Signal %lu does not exist"), id);
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 		gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 		return;
 	}
 
-	if (old_td->owner == g_thread_self ())
+	if (old_td->owner == g_thread_self ()) {
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
+		gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 		return;
+	}
 
         /* merge old_td and new_td */
         if (old_td->signals_list) {
@@ -1619,5 +1817,9 @@ gda_thread_wrapper_steal_signal (GdaThreadWrapper *wrapper, gulong id)
                 }
         }
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_rec_mutex_unlock (&(wrapper->priv->rmutex));
+#else
 	gda_mutex_unlock (wrapper->priv->mutex);
+#endif
 }
diff --git a/tools/browser/browser-connection-priv.h b/tools/browser/browser-connection-priv.h
index 1b30d11..8d0c03e 100644
--- a/tools/browser/browser-connection-priv.h
+++ b/tools/browser/browser-connection-priv.h
@@ -42,7 +42,11 @@ struct _BrowserConnectionPrivate {
         GdaSqlParser  *parser;
 
 	GdaDsnInfo     dsn_info;
+#if GLIB_CHECK_VERSION(2,31,7)
+	GMutex        mstruct_mutex;
+#else
 	GMutex        *p_mstruct_mutex;
+#endif
 	GSList        *p_mstruct_list; /* private GdaMetaStruct list: while they are being created */
 	GdaMetaStruct *c_mstruct; /* last GdaMetaStruct up to date, ready to be passed as @mstruct */
 	GdaMetaStruct *mstruct; /* public GdaMetaStruct: once it has been created and is no more modified */
diff --git a/tools/browser/browser-connection.c b/tools/browser/browser-connection.c
index d868997..2fbe778 100644
--- a/tools/browser/browser-connection.c
+++ b/tools/browser/browser-connection.c
@@ -353,7 +353,11 @@ browser_connection_init (BrowserConnection *bcnc)
 	bcnc->priv->parser = NULL;
 	bcnc->priv->variables = NULL;
 	memset (&(bcnc->priv->dsn_info), 0, sizeof (GdaDsnInfo));
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_init (&bcnc->priv->mstruct_mutex);
+#else
 	bcnc->priv->p_mstruct_mutex = g_mutex_new ();
+#endif
 	bcnc->priv->p_mstruct_list = NULL;
 	bcnc->priv->c_mstruct = NULL;
 	bcnc->priv->mstruct = NULL;
@@ -395,7 +399,11 @@ wrapper_meta_struct_sync (BrowserConnection *bcnc, GError **error)
 	gboolean retval = TRUE;
 	GdaMetaStruct *mstruct;
 
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_lock (&bcnc->priv->mstruct_mutex);
+#else
 	g_mutex_lock (bcnc->priv->p_mstruct_mutex);
+#endif
 	g_assert (bcnc->priv->p_mstruct_list);
 	mstruct = (GdaMetaStruct *) bcnc->priv->p_mstruct_list->data;
 	/*g_print ("%s() for GdaMetaStruct %p\n", __FUNCTION__, mstruct);*/
@@ -404,7 +412,11 @@ wrapper_meta_struct_sync (BrowserConnection *bcnc, GError **error)
 	if (bcnc->priv->p_mstruct_list) {
 		/* don't care about this one */
 		g_object_unref (G_OBJECT (mstruct));
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_mutex_unlock (&bcnc->priv->mstruct_mutex);
+#else
 		g_mutex_unlock (bcnc->priv->p_mstruct_mutex);
+#endif
 		return GINT_TO_POINTER (3);
 	}
 	else {
@@ -414,7 +426,11 @@ wrapper_meta_struct_sync (BrowserConnection *bcnc, GError **error)
 
 		/*g_print ("Meta struct sync for %p\n", mstruct);*/
 		retval = gda_meta_struct_complement_all (mstruct, error);
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_mutex_unlock (&bcnc->priv->mstruct_mutex);
+#else
 		g_mutex_unlock (bcnc->priv->p_mstruct_mutex);
+#endif
 	}
 
 #ifdef GDA_DEBUG_NO
@@ -446,12 +462,20 @@ meta_changed_cb (G_GNUC_UNUSED GdaThreadWrapper *wrapper,
 	GError *lerror = NULL;
 	GdaMetaStruct *mstruct;
 	
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_lock (&bcnc->priv->mstruct_mutex);
+#else
 	g_mutex_lock (bcnc->priv->p_mstruct_mutex);
+#endif
 	mstruct = gda_meta_struct_new (gda_connection_get_meta_store (bcnc->priv->cnc),
 				       GDA_META_STRUCT_FEATURE_ALL);
 	bcnc->priv->p_mstruct_list = g_slist_append (bcnc->priv->p_mstruct_list, mstruct);
 	/*g_print ("%s() Added %p to p_mstruct_list\n", __FUNCTION__, mstruct);*/
+#if GLIB_CHECK_VERSION(2,31,7)
+	g_mutex_unlock (&bcnc->priv->mstruct_mutex);
+#else
 	g_mutex_unlock (bcnc->priv->p_mstruct_mutex);
+#endif
 	job_id = gda_thread_wrapper_execute (bcnc->priv->wrapper,
 					     (GdaThreadWrapperFunc) wrapper_meta_struct_sync,
 					     g_object_ref (bcnc), g_object_unref, &lerror);
@@ -696,8 +720,12 @@ browser_connection_dispose (GObject *object)
 			g_slist_foreach (bcnc->priv->p_mstruct_list, (GFunc) g_object_unref, NULL);
 			g_slist_free (bcnc->priv->p_mstruct_list);
 		}
+#if GLIB_CHECK_VERSION(2,31,7)
+		g_mutex_clear (&bcnc->priv->mstruct_mutex);
+#else
 		if (bcnc->priv->p_mstruct_mutex)
 			g_mutex_free (bcnc->priv->p_mstruct_mutex);
+#endif
 
 		if (bcnc->priv->cnc)
 			g_object_unref (bcnc->priv->cnc);
@@ -780,7 +808,11 @@ check_for_wrapper_result (BrowserConnection *bcnc)
 				/* nothing to do */
 			}
 			else {
+#if GLIB_CHECK_VERSION(2,31,7)
+				g_mutex_lock (&bcnc->priv->mstruct_mutex);
+#else
 				g_mutex_lock (bcnc->priv->p_mstruct_mutex);
+#endif
 				
 				if (bcnc->priv->c_mstruct) {
 					GdaMetaStruct *old_mstruct;
@@ -802,7 +834,11 @@ check_for_wrapper_result (BrowserConnection *bcnc)
 #endif
 					g_signal_emit (bcnc, browser_connection_signals [META_CHANGED], 0, bcnc->priv->mstruct);
 				}
+#if GLIB_CHECK_VERSION(2,31,7)
+				g_mutex_unlock (&bcnc->priv->mstruct_mutex);
+#else
 				g_mutex_unlock (bcnc->priv->p_mstruct_mutex);
+#endif
 			}
 			break;
 		}
diff --git a/tools/browser/browser-page.c b/tools/browser/browser-page.c
index 7c8cb73..a25baf5 100644
--- a/tools/browser/browser-page.c
+++ b/tools/browser/browser-page.c
@@ -19,8 +19,15 @@
 
 #include "browser-page.h"
 #include "browser-perspective.h"
-
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex init_rmutex;
+#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
+#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
+#else
 static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+define MUTEX_LOCK() g_static_rec_mutex_lock(&init_mutex)
+#define MUTEX_UNLOCK() g_static_rec_mutex_unlock(&init_mutex)
+#endif
 static void browser_page_class_init (gpointer g_class);
 
 GType
@@ -42,12 +49,12 @@ browser_page_get_type (void)
 			0
 		};
 		
-		g_static_rec_mutex_lock (&init_mutex);
+		MUTEX_LOCK();
 		if (type == 0) {
 			type = g_type_register_static (G_TYPE_INTERFACE, "BrowserPage", &info, 0);
 			g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
 		}
-		g_static_rec_mutex_unlock (&init_mutex);
+		MUTEX_UNLOCK();
 	}
 	return type;
 }
@@ -57,11 +64,11 @@ browser_page_class_init (G_GNUC_UNUSED gpointer g_class)
 {
 	static gboolean initialized = FALSE;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	if (! initialized) {
 		initialized = TRUE;
 	}
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 }
 
 /**
diff --git a/tools/browser/browser-perspective.c b/tools/browser/browser-perspective.c
index 713e711..2361efc 100644
--- a/tools/browser/browser-perspective.c
+++ b/tools/browser/browser-perspective.c
@@ -22,7 +22,15 @@
 #include "browser-window.h"
 #include "support.h"
 
+#if GLIB_CHECK_VERSION(2,31,7)
+static GRecMutex init_rmutex;
+#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
+#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
+#else
 static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+define MUTEX_LOCK() g_static_rec_mutex_lock(&init_mutex)
+#define MUTEX_UNLOCK() g_static_rec_mutex_unlock(&init_mutex)
+#endif
 static void browser_perspective_class_init (gpointer g_class);
 
 GType
@@ -44,12 +52,12 @@ browser_perspective_get_type (void)
 			0
 		};
 		
-		g_static_rec_mutex_lock (&init_mutex);
+		MUTEX_LOCK();
 		if (type == 0) {
 			type = g_type_register_static (G_TYPE_INTERFACE, "BrowserPerspective", &info, 0);
 			g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
 		}
-		g_static_rec_mutex_unlock (&init_mutex);
+		MUTEX_UNLOCK();
 	}
 	return type;
 }
@@ -59,11 +67,11 @@ browser_perspective_class_init (G_GNUC_UNUSED gpointer g_class)
 {
 	static gboolean initialized = FALSE;
 
-	g_static_rec_mutex_lock (&init_mutex);
+	MUTEX_LOCK();
 	if (! initialized) {
 		initialized = TRUE;
 	}
-	g_static_rec_mutex_unlock (&init_mutex);
+	MUTEX_UNLOCK();
 }
 
 /**
diff --git a/tools/browser/common/objects-cloud.c b/tools/browser/common/objects-cloud.c
index 59818a4..7fb8aa9 100644
--- a/tools/browser/common/objects-cloud.c
+++ b/tools/browser/common/objects-cloud.c
@@ -526,8 +526,11 @@ static gboolean
 visibility_notify_event (GtkWidget *text_view, G_GNUC_UNUSED GdkEventVisibility *event, ObjectsCloud *cloud)
 {
 	gint wx, wy, bx, by;
-
-	gdk_window_get_pointer (gtk_widget_get_window (text_view), &wx, &wy, NULL);
+	GdkDeviceManager *manager;
+	GdkDevice *pointer;
+	manager = gdk_display_get_device_manager (gtk_widget_get_display (text_view));
+	pointer = gdk_device_manager_get_client_pointer (manager);
+	gdk_window_get_device_position (gtk_widget_get_window (text_view), pointer, &wx, &wy, NULL);
 	
 	gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), 
 					       GTK_TEXT_WINDOW_WIDGET,
@@ -551,7 +554,6 @@ motion_notify_event (GtkWidget *text_view, GdkEventMotion *event, ObjectsCloud *
 					       event->x, event->y, &x, &y);
 	
 	set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y, cloud);
-	gdk_window_get_pointer (gtk_widget_get_window (text_view), NULL, NULL, NULL);
 	return FALSE;
 }
 



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