]> git.mxchange.org Git - flightgear.git/commitdiff
Check for an empty search query in GPS searches, and fix test code.
authorjmt <jmt>
Tue, 27 Oct 2009 19:23:56 +0000 (19:23 +0000)
committerTim Moore <timoore@redhat.com>
Tue, 27 Oct 2009 21:22:03 +0000 (22:22 +0100)
src/Instrumentation/gps.cxx
src/Instrumentation/testgps.cxx

index 1ef7dfcd1d0d6b6ddb587dbe21e051bf202e823e..4477dd4eddaf23e5ce1e77b7ad6a0ddfda24694a 100644 (file)
@@ -1492,6 +1492,12 @@ void GPS::search()
   string sty(_scratchNode->getStringValue("type"));
   _searchType = FGPositioned::typeFromName(sty);
   _searchQuery = _scratchNode->getStringValue("query");
+  if (_searchQuery.empty()) {
+    SG_LOG(SG_INSTR, SG_WARN, "empty GPS search query");
+    clearScratch();
+    return;
+  }
+  
   _searchExact = _scratchNode->getBoolValue("exact", true);
   _searchOrderByRange = _scratchNode->getBoolValue("order-by-distance", true);
   _searchResultIndex = 0;
index 23e491b179248731e4a304c91a4a9438fcff2f69..64060041cf2e653bc3b6d26af9b8833e03cdb95c 100644 (file)
@@ -102,7 +102,7 @@ int main(int argc, char* argv[])
   gps->update(0.05);
   gps->update(0.05);
   
-  scratch->setStringValue("ident", "TL");
+  scratch->setStringValue("query", "TL");
   scratch->setStringValue("type", "Vor");
   scratch->setBoolValue("exact", false);
   nd->setStringValue("command", "search");
@@ -118,7 +118,7 @@ int main(int argc, char* argv[])
   nd->setDoubleValue("config/min-runway-length-ft", 5000.0);
   scratch->setBoolValue("exact", false);
   scratch->setBoolValue("order-by-distance", false);
-  scratch->setStringValue("ident", "KS");
+  scratch->setStringValue("query", "KS");
   scratch->setStringValue("type", "apt");
   
   nd->setStringValue("command", "search");
@@ -134,7 +134,7 @@ int main(int argc, char* argv[])
   scratch->setBoolValue("exact", true);
   scratch->setBoolValue("order-by-distance", true);
   scratch->setStringValue("type", "vor");
-  scratch->setStringValue("ident", "DCS");
+  scratch->setStringValue("query", "DCS");
   
   nd->setStringValue("command", "search");
   printScratch(scratch);
@@ -145,7 +145,7 @@ int main(int argc, char* argv[])
 // search on totally missing
   scratch->setBoolValue("exact", true);
   scratch->setBoolValue("order-by-distance", true);
-  scratch->setStringValue("ident", "FOFOFOFOF");
+  scratch->setStringValue("query", "FOFOFOFOF");
   nd->setStringValue("command", "search");
   printScratch(scratch);
   
@@ -168,7 +168,7 @@ int main(int argc, char* argv[])
     << " " << wp1->getDoubleValue("latitude-deg"));
 
 // OBS mode
-  scratch->setStringValue("ident", "UW");
+  scratch->setStringValue("query", "UW");
   scratch->setBoolValue("order-by-distance", true);
   nd->setStringValue("command", "search");
   printScratch(scratch);