]> git.mxchange.org Git - flightgear.git/commitdiff
Change the way the nav-cache is rebuilt.
authorJames Turner <zakalawe@mac.com>
Sun, 3 Feb 2013 22:24:40 +0000 (22:24 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 3 Feb 2013 22:24:40 +0000 (22:24 +0000)
Instead of deleting all table contents, actually remove the entire file on disk and re-create. This is fractionally more work, but removes any possibility of stale indices or missing deletes causing clutter after rebuilds. My suspicion is, this is cause the erratic performance some people have seen with the airports search dialog, so will back-port to 2.10.

src/Navaids/NavDataCache.cxx

index 0a09c3187cb4c8dc824ad42037b9a7c49eb76646..e4d681eec5c150cfbc5fd125fdecddbaedade2da 100644 (file)
@@ -206,12 +206,7 @@ public:
   
   ~NavDataCachePrivate()
   {
-    BOOST_FOREACH(sqlite3_stmt_ptr stmt, prepared) {
-      sqlite3_finalize(stmt);
-    }
-    prepared.clear();
-    
-    sqlite3_close(db);
+    close();
   }
   
   void init()
@@ -257,6 +252,15 @@ public:
     prepareQueries();
   }
   
+  void close()
+  {
+    BOOST_FOREACH(sqlite3_stmt_ptr stmt, prepared) {
+      sqlite3_finalize(stmt);
+    }
+    prepared.clear();
+    sqlite3_close(db);
+  }
+  
   void checkCacheFile()
   {
     SG_LOG(SG_NAVCACHE, SG_INFO, "running DB integrity check");
@@ -1179,20 +1183,11 @@ bool NavDataCache::rebuild()
 void NavDataCache::doRebuild()
 {
   try {
-    Transaction txn(this);
-    d->runSQL("DELETE FROM positioned");
-    d->runSQL("DELETE FROM airport");
-    d->runSQL("DELETE FROM runway");
-    d->runSQL("DELETE FROM navaid");
-    d->runSQL("DELETE FROM comm");
-    d->runSQL("DELETE FROM octree");
-    d->runSQL("DELETE FROM airway");
-    d->runSQL("DELETE FROM airway_edge");
-    d->runSQL("DELETE FROM taxi_node");
-    d->runSQL("DELETE FROM parking");
-    d->runSQL("DELETE FROM groundnet_edge");
-    d->runSQL("DELETE FROM stat_cache");
+    d->close(); // completely close the sqlite object
+    d->path.remove(); // remove the file on disk
+    d->init(); // star again from scratch
     
+    Transaction txn(this);
   // initialise the root octree node
     d->runSQL("INSERT INTO octree (rowid, children) VALUES (1, 0)");