[gcompris] core: no more crash if we fail to write to the database.



commit c019f40c59a3abb9ca3e0deee97399d4e5985ba3
Author: Lavanya gunasekaran <lavanyagunasekar gmail com>
Date:   Wed Apr 4 01:43:04 2012 +0200

    core: no more crash if we fail to write to the database.
    
    This fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=665258

 src/gcompris/gcompris_db.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/gcompris/gcompris_db.c b/src/gcompris/gcompris_db.c
index 7fef100..8664d70 100644
--- a/src/gcompris/gcompris_db.c
+++ b/src/gcompris/gcompris_db.c
@@ -2099,6 +2099,7 @@ gboolean gc_db_log(gchar *date, int duration,
   SUPPORT_OR_RETURN(FALSE);
 
 #ifdef USE_SQLITE
+  static gboolean got_error = FALSE;
   char *zErrMsg;
   int rc;
   gchar *request;
@@ -2109,8 +2110,15 @@ gboolean gc_db_log(gchar *date, int duration,
 			    date, duration, user_id, board_id, level, sublevel, status, comment_quoted);
 
   rc = sqlite3_exec(gcompris_db, request, NULL,  0, &zErrMsg);
-  if( rc!=SQLITE_OK ){
-    g_error("SQL error: %s\n", zErrMsg);
+  if ( rc != SQLITE_OK && ! got_error ) {
+    got_error = TRUE;
+    GcomprisProperties	*properties = gc_prop_get();
+    gchar *msg = g_strdup_printf("Failed to write to our database '%s' with error: %s",
+				 properties->database, zErrMsg);
+    gc_dialog( msg, NULL);
+    g_free(msg);
+    sqlite3_free(zErrMsg);
+    return TRUE;
   }
 
   if(comment)



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