]> git.mxchange.org Git - flightgear.git/commitdiff
Bugfix: guard against corrupted airport XML.
authorJames Turner <zakalawe@mac.com>
Tue, 14 Jan 2014 13:42:11 +0000 (13:42 +0000)
committerJames Turner <zakalawe@mac.com>
Tue, 14 Jan 2014 13:42:11 +0000 (13:42 +0000)
src/Airports/airport.cxx

index 2b6020d9f64271d8ed633b4dd90c8ba8d00a9b5f..1a1fa7b1a1a50b27229a09e9c8e9104f8f047b60 100644 (file)
@@ -570,12 +570,16 @@ void FGAirport::loadSceneryDefinitions() const
     return;
   }
   
-    flightgear::NavDataCache::Transaction txn(cache);
-    SGPropertyNode_ptr rootNode = new SGPropertyNode;
-    readProperties(path.str(), rootNode);
-    const_cast<FGAirport*>(this)->readThresholdData(rootNode);
-    cache->stampCacheFile(path);
-    txn.commit();
+    try {
+        flightgear::NavDataCache::Transaction txn(cache);
+        SGPropertyNode_ptr rootNode = new SGPropertyNode;
+        readProperties(path.str(), rootNode);
+        const_cast<FGAirport*>(this)->readThresholdData(rootNode);
+        cache->stampCacheFile(path);
+        txn.commit();
+    } catch (sg_exception& e) {
+        SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading threshold XML failed:" << e.getFormattedMessage());
+    }
 }
 
 void FGAirport::readThresholdData(SGPropertyNode* aRoot)
@@ -653,13 +657,17 @@ void FGAirport::validateTowerData() const
   // cached values are correct, we're all done
     return;
   }
-   
-  flightgear::NavDataCache::Transaction txn(cache);
-  SGPropertyNode_ptr rootNode = new SGPropertyNode;
-  readProperties(path.str(), rootNode);
-  const_cast<FGAirport*>(this)->readTowerData(rootNode);
-  cache->stampCacheFile(path);
-  txn.commit();
+
+    try {
+        flightgear::NavDataCache::Transaction txn(cache);
+        SGPropertyNode_ptr rootNode = new SGPropertyNode;
+        readProperties(path.str(), rootNode);
+        const_cast<FGAirport*>(this)->readTowerData(rootNode);
+        cache->stampCacheFile(path);
+        txn.commit();
+    } catch (sg_exception& e){
+        SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading twr XML failed:" << e.getFormattedMessage());
+    }
 }
 
 void FGAirport::readTowerData(SGPropertyNode* aRoot)
@@ -706,16 +714,21 @@ bool FGAirport::validateILSData()
     return false;
   }
   
-  SGPropertyNode_ptr rootNode = new SGPropertyNode;
-  readProperties(path.str(), rootNode);
+    try {
+        SGPropertyNode_ptr rootNode = new SGPropertyNode;
+        readProperties(path.str(), rootNode);
 
-  flightgear::NavDataCache::Transaction txn(cache);
-  readILSData(rootNode);
-  cache->stampCacheFile(path);
-  txn.commit();
-    
+        flightgear::NavDataCache::Transaction txn(cache);
+        readILSData(rootNode);
+        cache->stampCacheFile(path);
+        txn.commit();
 // we loaded data, tell the caller it might need to reload things
-  return true;
+        return true;
+    } catch (sg_exception& e){
+        SG_LOG(SG_NAVAID, SG_WARN, ident() << "loading ils XML failed:" << e.getFormattedMessage());
+    }
+    
+    return false;
 }
 
 void FGAirport::readILSData(SGPropertyNode* aRoot)