[libgda] VConnection: Fixed parsing error for GdaDataModelArray from types



commit 93f9ae1b8b49896b779f4484a8df73da0506ba4d
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Aug 1 18:45:53 2018 -0500

    VConnection: Fixed parsing error for GdaDataModelArray from types
    
    This fix a segfault when trying to create a virtual connection
    on GDA Browser

 libgda/gda-data-model-array.c                 | 4 ++--
 libgda/gda-holder.c                           | 7 ++++---
 libgda/gda-util.c                             | 8 +++++---
 tools/browser/connection-binding-properties.c | 4 ++--
 4 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/libgda/gda-data-model-array.c b/libgda/gda-data-model-array.c
index 7d65827c0..0ffe6c6a0 100644
--- a/libgda/gda-data-model-array.c
+++ b/libgda/gda-data-model-array.c
@@ -311,13 +311,13 @@ gda_data_model_array_new_with_g_types (gint cols, ...)
        va_start (args, cols);
        i = 0;
        while (i < cols) {
-               gint argtype;
+               GType argtype;
 
                argtype = va_arg (args, GType);
                g_assert (argtype >= 0);
 
                gda_column_set_g_type (gda_data_model_describe_column (model, i), 
-                                        (GType) argtype);
+                                        argtype);
                i++;
        }
        va_end (args);
diff --git a/libgda/gda-holder.c b/libgda/gda-holder.c
index 01439ff4d..ea84cefd6 100644
--- a/libgda/gda-holder.c
+++ b/libgda/gda-holder.c
@@ -1635,8 +1635,9 @@ gda_holder_set_source_model (GdaHolder *holder, GdaDataModel *model,
 {
        g_return_val_if_fail (GDA_IS_HOLDER (holder), FALSE);
        g_return_val_if_fail (holder->priv, FALSE);
-       if (model)
-               g_return_val_if_fail (GDA_IS_DATA_MODEL (model), FALSE);
+  g_return_val_if_fail (model != NULL, FALSE);
+       g_return_val_if_fail (GDA_IS_DATA_MODEL (model), FALSE);
+       g_return_val_if_fail (col >= 0 && col < gda_data_model_get_n_columns (model), FALSE);
 
        /* No check is done on the validity of @col or even its existance */
        /* Note: for internal implementation if @col<0, then it's ignored */
@@ -1650,7 +1651,7 @@ gda_holder_set_source_model (GdaHolder *holder, GdaDataModel *model,
                if (gcol) {
                        ctype = gda_column_get_g_type (gcol);
                        if ((htype != GDA_TYPE_NULL) && (ctype != GDA_TYPE_NULL) &&
-                           (htype != ctype)) {
+          (htype != ctype)) {
                                g_set_error (error, GDA_HOLDER_ERROR, GDA_HOLDER_VALUE_TYPE_ERROR,
                                             _("GdaHolder has a gda type (%s) incompatible with "
                                                "source column %d type (%s)"),
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index 6387c8303..e3482c069 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -81,7 +81,9 @@ extern GdaAttributesManager *gda_holder_attributes_manager;
 const gchar *
 gda_g_type_to_string (GType type)
 {
-       if (type == GDA_TYPE_NULL)
+       if (type == G_TYPE_INVALID)
+    return "null";
+       else if (type == GDA_TYPE_NULL)
                return "null";
        else if (type == G_TYPE_INT)
                return "int";
@@ -99,7 +101,7 @@ gda_g_type_to_string (GType type)
                return "blob";
        else if (type == GDA_TYPE_BINARY)
                return "binary";
-       else 
+  else
                return g_type_name (type);
 }
 
@@ -181,7 +183,7 @@ gda_g_type_from_string (const gchar *str)
                        type = G_TYPE_INVALID;
        }
 
-       return type;
+  return type;
 }
 
 /**
diff --git a/tools/browser/connection-binding-properties.c b/tools/browser/connection-binding-properties.c
index 4c697ece5..0b372f326 100644
--- a/tools/browser/connection-binding-properties.c
+++ b/tools/browser/connection-binding-properties.c
@@ -157,7 +157,7 @@ connection_binding_properties_new_create (TConnection *tcnc)
        part = g_new0 (TVirtualConnectionPart, 1);
        part->part_type = T_VIRTUAL_CONNECTION_PART_CNC;
        part->u.cnc.table_schema = g_strdup (t_connection_get_name (tcnc));
-       part->u.cnc.source_cnc = g_object_ref (G_OBJECT (tcnc));
+       part->u.cnc.source_cnc = T_CONNECTION (g_object_ref (G_OBJECT (tcnc)));
        specs->parts = g_slist_append (NULL, part);
 
        cprop = CONNECTION_BINDING_PROPERTIES (g_object_new (CONNECTION_TYPE_BINDING_PROPERTIES, NULL));
@@ -563,7 +563,7 @@ create_part_for_cnc (ConnectionBindingProperties *cprop, TVirtualConnectionPart
        g_assert (gda_holder_set_value (holder, value, NULL));
        gda_value_free (value);
 
-       g_assert (gda_holder_set_source_model (holder, t_app_get_all_connections_m (),
+  g_assert (gda_holder_set_source_model (holder, t_app_get_all_connections_m (),
                                               CNC_LIST_COLUMN_TCNC, NULL));
        g_object_unref (holder);
 


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