[anjuta] symbol-db: avoid crash if db doesn't exist.
- From: Massimo Cora' <mcora src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] symbol-db: avoid crash if db doesn't exist.
- Date: Thu, 23 Jul 2009 10:27:05 +0000 (UTC)
commit 63463eb15d18d97a9fb8ba36c0717a42fef59e6c
Author: Massimo Corà <mcora src gnome org>
Date: Thu Jul 23 12:25:21 2009 +0200
symbol-db: avoid crash if db doesn't exist.
Added also a getter to know the current libgda connection string.
plugins/symbol-db/symbol-db-engine-core.c | 17 ++++++++++++++++-
plugins/symbol-db/symbol-db-engine-core.h | 6 ++++++
2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index 9f0c8e7..4110b9a 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -3031,6 +3031,7 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
SymbolDBEnginePriv *priv;
gboolean needs_tables_creation = FALSE;
gchar *cnc_string;
+ gboolean connect_res;
DEBUG_PRINT ("Opening project %s with base dir %s",
prj_directory, base_db_path);
@@ -3062,9 +3063,12 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
DEBUG_PRINT ("Connecting to "
"database with %s...", cnc_string);
- sdb_engine_connect_to_db (dbe, cnc_string);
+ connect_res = sdb_engine_connect_to_db (dbe, cnc_string);
g_free (cnc_string);
+ if (connect_res == FALSE)
+ return FALSE;
+
if (needs_tables_creation == TRUE)
{
DEBUG_PRINT ("Creating tables: it needs tables...");
@@ -3084,6 +3088,17 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
return TRUE;
}
+gchar *
+symbol_db_engine_get_cnc_string (SymbolDBEngine * dbe)
+{
+ SymbolDBEnginePriv *priv;
+
+ g_return_val_if_fail (dbe != NULL, FALSE);
+ priv = dbe->priv;
+
+ return g_strdup (priv->cnc_string);
+}
+
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean
symbol_db_engine_add_new_workspace (SymbolDBEngine * dbe,
diff --git a/plugins/symbol-db/symbol-db-engine-core.h b/plugins/symbol-db/symbol-db-engine-core.h
index dc1efcc..68ebd5d 100644
--- a/plugins/symbol-db/symbol-db-engine-core.h
+++ b/plugins/symbol-db/symbol-db-engine-core.h
@@ -111,6 +111,12 @@ gboolean
symbol_db_engine_is_connected (SymbolDBEngine * dbe);
/**
+ * Getter for the connection string. Returned char must be freed by caller.
+ */
+gchar *
+symbol_db_engine_get_cnc_string (SymbolDBEngine * dbe);
+
+/**
* Check if the database already exists into the prj_directory
*/
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]