[tracker/collator] libtracker-data: Handle error case when resetting collator



commit 8a4ecff67190ce9032ed1d4a3fb09c98512b4047
Author: JÃrg Billeter <j bitron ch>
Date:   Mon Dec 5 16:21:08 2011 +0100

    libtracker-data: Handle error case when resetting collator
    
    Fixes NB#293766.

 src/libtracker-data/tracker-db-interface-sqlite.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 7e8779d..68a59a2 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1039,22 +1039,29 @@ tracker_db_interface_sqlite_fts_update_rollback (TrackerDBInterface *db_interfac
 void
 tracker_db_interface_sqlite_reset_collator (TrackerDBInterface *db_interface)
 {
+	gpointer newcollator;
+
 	g_debug ("Resetting collator in db interface %p", db_interface);
 
-	if (db_interface->collator) {
-		tracker_collation_shutdown (db_interface->collator);
-	}
+	newcollator = tracker_collation_init ();
 
-	db_interface->collator = tracker_collation_init ();
 	/* This will overwrite any other collation set before, if any */
 	if (sqlite3_create_collation (db_interface->db,
 	                              TRACKER_COLLATION_NAME,
 	                              SQLITE_UTF8,
 	                              db_interface->collator,
-	                              tracker_collation_utf8) != SQLITE_OK)
-	{
+	                              tracker_collation_utf8) == SQLITE_OK) {
+		/* replacing collator was successful, shut down old collator */
+		if (db_interface->collator) {
+			tracker_collation_shutdown (db_interface->collator);
+		}
+
+		db_interface->collator = newcollator;
+	} else {
 		g_critical ("Couldn't set collation function: %s",
 		            sqlite3_errmsg (db_interface->db));
+
+		tracker_collation_shutdown (newcollator);
 	}
 }
 



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