[libgda/gtk3] Misc. corrections



commit d9928de3917505847cd282e4347787e6fdb7ab6c
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sat Feb 19 15:30:01 2011 +0100

    Misc. corrections

 libgda/gda-quark-list.c                            |   18 +++++++++++--
 libgda/sqlite/virtual/gda-vconnection-data-model.c |   17 ++++++++++++
 libgda/sqlite/virtual/gda-vprovider-data-model.c   |   27 +++++++++----------
 3 files changed, 45 insertions(+), 17 deletions(-)
---
diff --git a/libgda/gda-quark-list.c b/libgda/gda-quark-list.c
index fae89be..cd51a4e 100644
--- a/libgda/gda-quark-list.c
+++ b/libgda/gda-quark-list.c
@@ -1,5 +1,5 @@
 /* GDA Common Library
- * Copyright (C) 1998 - 2010 The GNOME Foundation.
+ * Copyright (C) 1998 - 2011 The GNOME Foundation.
  *
  * Authors:
  *	Rodrigo Moya <rodrigo gnome-db org>
@@ -192,6 +192,16 @@ gda_quark_list_add_from_string (GdaQuarkList *qlist, const gchar *string, gboole
 
 		while (arr[n] && (* (arr[n]))) {
 			gchar **pair;
+			gchar *tmp;
+			for (tmp = arr[n]; *tmp; tmp++) {
+				if (*tmp == '=')
+					break;
+			}
+			if (!*tmp) {
+				/* ignore this string since it does not contain the '=' char */
+				n++;
+				continue;
+			}
 
 			pair = (gchar **) g_strsplit (arr[n], "=", 2);
 			if (pair && pair[0]) {
@@ -199,8 +209,10 @@ gda_quark_list_add_from_string (GdaQuarkList *qlist, const gchar *string, gboole
 				gchar *value = pair[1];
 				g_strstrip (name);
 				gda_rfc1738_decode (name);
-				g_strstrip (value);
-				gda_rfc1738_decode (value);
+				if (value) {
+					g_strstrip (value);
+					gda_rfc1738_decode (value);
+				}
 				g_hash_table_insert (qlist->hash_table, 
 						     (gpointer) name, (gpointer) value);
 				g_free (pair);
diff --git a/libgda/sqlite/virtual/gda-vconnection-data-model.c b/libgda/sqlite/virtual/gda-vconnection-data-model.c
index 8b66133..f3b5417 100644
--- a/libgda/sqlite/virtual/gda-vconnection-data-model.c
+++ b/libgda/sqlite/virtual/gda-vconnection-data-model.c
@@ -171,6 +171,22 @@ spec_destroy_func (GdaVconnectionDataModelSpec *spec)
 	g_free (spec);
 }
 
+static GList *
+create_columns (GdaVconnectionDataModelSpec *spec)
+{
+	g_return_val_if_fail (spec->data_model, NULL);
+
+	GList *columns = NULL;
+	guint i, ncols;
+	ncols = gda_data_model_get_n_columns (spec->data_model);
+	for (i = 0; i < ncols; i++) {
+		GdaColumn *mcol = gda_data_model_describe_column (spec->data_model, i);
+		GdaColumn *ccol = gda_column_copy (mcol);
+		columns = g_list_prepend (columns, ccol);
+	}
+	return g_list_reverse (columns);
+}
+
 /**
  * gda_vconnection_data_model_add_model
  * @cnc: a #GdaVconnectionDataModel connection
@@ -195,6 +211,7 @@ gda_vconnection_data_model_add_model (GdaVconnectionDataModel *cnc,
 
 	spec = g_new0 (GdaVconnectionDataModelSpec, 1);
 	spec->data_model = model;
+	spec->create_columns_func = create_columns;
 	g_object_ref (model);
 	retval = gda_vconnection_data_model_add (cnc, spec, (GDestroyNotify) spec_destroy_func, table_name, error);
 
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index 293189c..5135449 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -353,22 +353,21 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
 		td->real_model = td->spec->data_model;
 		g_object_ref (td->real_model);
 	}
-	else  {
-		GError *error = NULL;
-		if (!td->columns)
-			td->columns = td->spec->create_columns_func (td->spec, &error);
-		if (! td->columns) {
-			if (error && error->message) {
-				int len = strlen (error->message) + 1;
-				*pzErr = SQLITE3_CALL (sqlite3_malloc) (sizeof (gchar) * len);
-				memcpy (*pzErr, error->message, len); /* Flawfinder: ignore */
-			}
-			else 
-				*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Could not compute virtual table's columns"));
-			return SQLITE_ERROR;
+
+	GError *error = NULL;
+	if (!td->columns && td->spec->create_columns_func)
+		td->columns = td->spec->create_columns_func (td->spec, &error);
+	if (! td->columns) {
+		if (error && error->message) {
+			int len = strlen (error->message) + 1;
+			*pzErr = SQLITE3_CALL (sqlite3_malloc) (sizeof (gchar) * len);
+			memcpy (*pzErr, error->message, len); /* Flawfinder: ignore */
 		}
-		ncols = g_list_length (td->columns);
+		else 
+			*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Could not compute virtual table's columns"));
+		return SQLITE_ERROR;
 	}
+	ncols = g_list_length (td->columns);
 	td->n_columns = ncols;
 
 	/* create the CREATE TABLE statement */



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