[libgda] Make sure the GdaConnection::is-wrapper property is not modified outside Libgda's code



commit 345adb64d8bef9d998c2d687ff7d3968a627ea86
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon Mar 11 22:00:06 2013 +0100

    Make sure the GdaConnection::is-wrapper property is not modified outside Libgda's code

 libgda/gda-connection-internal.h            |    2 ++
 libgda/gda-connection.c                     |   18 ++++++++++++++++--
 libgda/thread-wrapper/gda-thread-provider.c |    3 ++-
 3 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/libgda/gda-connection-internal.h b/libgda/gda-connection-internal.h
index 96ffd45..66c25fa 100644
--- a/libgda/gda-connection-internal.h
+++ b/libgda/gda-connection-internal.h
@@ -77,6 +77,8 @@ void                  _gda_thread_connection_data_free (ThreadConnectionData *cd
 void                  _gda_connection_force_transaction_status (GdaConnection *cnc, GdaConnection 
*wrapped_cnc);
 GdaServerProvider    *_gda_connection_get_internal_thread_provider (void);
 
+void                  _gda_connection_define_as_thread_wrapper (GdaConnection *cnc);
+
 /*
  * Used by virtual connections to keep meta data up to date when a table
  * is added or removed, without using the update_meta_store_after_statement_exec()
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 7b5ce8b..adba0dc 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -382,13 +382,21 @@ gda_connection_class_init (GdaConnectionClass *klass)
        /**
         * GdaConnection:is-wrapper:
         *
+        * This property, if set to %TRUE, specifies that the connection is not a real connection, but rather
+        * a #GdaConnection object which "proxies" all the calls to another connection which executes in a sub
+        * thread.
+        *
+        * Note: this property is used internally by Libgda and should not be directly used by any programs. 
Setting
+        * this property has no effect, reading it is supported, though.
+        *
         * Since: 4.2
         **/
        g_object_class_install_property (object_class, PROP_IS_THREAD_WRAPPER,
                                         g_param_spec_boolean ("is-wrapper", NULL,
-                                                              _("Tells if the connection acts as a thread 
wrapper around another connection, making it completely thread safe"),
+                                                              _("Determines if the connection acts as a 
thread wrapper around another connection, making it completely thread safe"),
                                                               FALSE,
                                                               (G_PARAM_READABLE | G_PARAM_WRITABLE | 
G_PARAM_CONSTRUCT_ONLY)));
+
        /**
         * GdaConnection:monitor-wrapped-in-mainloop:
         *
@@ -705,6 +713,12 @@ monitor_wrapped_cnc (GdaThreadWrapper *wrapper)
        return TRUE; /* don't remove the monitoring */
 }
 
+void
+_gda_connection_define_as_thread_wrapper (GdaConnection *cnc)
+{
+       cnc->priv->is_thread_wrapper = TRUE;
+}
+
 static void
 gda_connection_set_property (GObject *object,
                             guint param_id,
@@ -891,7 +905,7 @@ gda_connection_set_property (GObject *object,
 #endif
                        break;
                case PROP_IS_THREAD_WRAPPER:
-                       cnc->priv->is_thread_wrapper = g_value_get_boolean (value);
+                       g_warning ("This property should not be modified!");
                        break;
                case PROP_MONITOR_WRAPPED_IN_MAINLOOP:
                        if (cnc->priv->is_thread_wrapper) {
diff --git a/libgda/thread-wrapper/gda-thread-provider.c b/libgda/thread-wrapper/gda-thread-provider.c
index 2a8f6dd..7292692 100644
--- a/libgda/thread-wrapper/gda-thread-provider.c
+++ b/libgda/thread-wrapper/gda-thread-provider.c
@@ -327,7 +327,8 @@ gda_thread_provider_create_connection (GdaServerProvider *provider)
        GdaConnection *cnc;
         g_return_val_if_fail (GDA_IS_THREAD_PROVIDER (provider), NULL);
 
-        cnc = g_object_new (GDA_TYPE_CONNECTION, "provider", provider, "is-wrapper", TRUE, NULL);
+        cnc = g_object_new (GDA_TYPE_CONNECTION, "provider", provider, NULL);
+       _gda_connection_define_as_thread_wrapper (cnc);
 
         return cnc;
 }


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