[libgda] Misc corrections



commit f320f6f5b28b6fbf38e1c182f5c21b98666b4ec0
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Dec 17 19:17:48 2009 +0100

    Misc corrections

 libgda/gda-set.c                    |    2 +-
 libgda/sqlite/gda-sqlite-provider.c |   33 +++++++++++++++++++++++----------
 2 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 6eaa480..315fd8c 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -1319,7 +1319,7 @@ GdaHolder *
 gda_set_get_holder (GdaSet *set, const gchar *holder_id)
 {
 	g_return_val_if_fail (GDA_IS_SET (set), NULL);
-	g_return_val_if_fail (set->priv, NULL);
+	g_return_val_if_fail (holder_id, NULL);
 
 	return (GdaHolder *) g_hash_table_lookup (set->priv->holders_hash, holder_id);
 }
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 086e6e8..4d8d393 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -2053,7 +2053,7 @@ fill_blob_data (GdaConnection *cnc, GdaSet *params,
 		/* nothing to do */
 		return NULL;
 
-	const gchar *str = NULL;
+	const gchar *cstr = NULL;
 	GdaStatement *stmt;
 	sqlite3_int64 rowid = -1;
 	GdaDataModel *model = NULL;
@@ -2104,11 +2104,11 @@ fill_blob_data (GdaConnection *cnc, GdaSet *params,
 			GdaSqliteBlobOp *bop;
 			bop = (GdaSqliteBlobOp*) _gda_sqlite_blob_op_new (cdata, pb->db, pb->table, pb->column, rowid);
 			if (!bop) {
-				str =  _("Can't create SQLite BLOB handle");
+				cstr =  _("Can't create SQLite BLOB handle");
 				goto blobs_out;
 			}
 			if (gda_blob_op_write (GDA_BLOB_OP (bop), pb->blob, 0) < 0) {
-				str =  _("Can't write to SQLite's BLOB");
+				cstr =  _("Can't write to SQLite's BLOB");
 				g_object_unref (bop);
 				goto blobs_out;
 			}
@@ -2124,16 +2124,29 @@ fill_blob_data (GdaConnection *cnc, GdaSet *params,
 					g_object_unref (model);
 					goto blobs_out;
 				}
-				rowid = g_value_get_int64 (cvalue);
+				if (G_VALUE_TYPE (cvalue) == G_TYPE_INT64)
+					rowid = g_value_get_int64 (cvalue);
+				else if (G_VALUE_TYPE (cvalue) == G_TYPE_INT)
+					rowid = g_value_get_int (cvalue);
+				else {
+					g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
+						     GDA_SERVER_PROVIDER_INTERNAL_ERROR,
+						     _("Can't obtain SQLite BLOB handle (reported type is '%s'), "
+						       "please report this bug to "
+						       "http://bugzilla.gnome.org/ for the \"libgda\" product."),
+						       g_type_name (G_VALUE_TYPE (cvalue)));
+					g_object_unref (model);
+					goto blobs_out;
+				}
 				GdaSqliteBlobOp *bop;
 				bop = (GdaSqliteBlobOp*) _gda_sqlite_blob_op_new (cdata, pb->db, pb->table, pb->column, rowid);
 				if (!bop) {
-					str =  _("Can't create SQLite BLOB handle");
+					cstr =  _("Can't create SQLite BLOB handle");
 					g_object_unref (model);
 					goto blobs_out;
 				}
 				if (gda_blob_op_write (GDA_BLOB_OP (bop), pb->blob, 0) < 0) {
-					str =  _("Can't write to SQLite's BLOB");
+					cstr =  _("Can't write to SQLite's BLOB");
 					g_object_unref (bop);
 					g_object_unref (model);
 					goto blobs_out;
@@ -2143,18 +2156,18 @@ fill_blob_data (GdaConnection *cnc, GdaSet *params,
 			g_object_unref (model);
 		}
 		else
-			str = _("Can't identify the ROWID of the blob to fill");
+			cstr = _("Can't identify the ROWID of the blob to fill");
 	}
 		
  blobs_out:
 	pending_blobs_free_list (blobs_list);
 
-	if (str) {
+	if (cstr) {
 		GdaConnectionEvent *event;
 		event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
-		gda_connection_event_set_description (event, str);
+		gda_connection_event_set_description (event, cstr);
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
-			     GDA_SERVER_PROVIDER_DATA_ERROR, "%s", str);
+			     GDA_SERVER_PROVIDER_DATA_ERROR, "%s", cstr);
 		return event;
 	}
 	if (lerror) {



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