]> git.mxchange.org Git - flightgear.git/commitdiff
Fix random crash on exit in atc_mgr
authorTorsten Dreyer <torsten@t3r.de>
Wed, 10 Jun 2015 10:04:47 +0000 (12:04 +0200)
committerTorsten Dreyer <torsten@t3r.de>
Wed, 10 Jun 2015 10:04:47 +0000 (12:04 +0200)
make the ParkingAssignment a local object instead of
creating it on the heap as a member of the ATCManager

src/ATC/atc_mgr.cxx

index b51bbd46d84c1191e1590d0c24062a23f8d32f20..0116c68ba0c5a6bb2b259d07cd7a8eee6bdd9cd5 100644 (file)
 
 using std::string;
 
-FGATCManager::FGATCManager() {
-    controller = 0;
-    prevController = 0;
-    networkVisible = false;
-    initSucceeded  = false;
+FGATCManager::FGATCManager() :
+    controller(NULL),
+    prevController(NULL),
+    networkVisible(false),
+    initSucceeded(false)
+{
 }
 
 FGATCManager::~FGATCManager() {
-    delete pk;
 }
 
 void FGATCManager::init() {
@@ -105,11 +105,11 @@ void FGATCManager::init() {
     FGAirport *apt = FGAirport::findByIdent(airport); 
     if (apt && onGround) {// && !runway.empty()) {
         FGAirportDynamics* dcs = apt->getDynamics();
-         pk = new ParkingAssignment(dcs->getParkingByName(parking));
+        ParkingAssignment pk(dcs->getParkingByName(parking));
       
         // No valid parking location, so either at the runway or at a random location.
-        if (pk->isValid()) {
-            dcs->setParkingAvailable(pk->parking()->guid(), false);
+        if (pk.isValid()) {
+            dcs->setParkingAvailable(pk.parking()->guid(), false);
             fp = new FGAIFlightPlan;
             controller = apt->getDynamics()->getStartupController();
             int stationFreq = apt->getDynamics()->getGroundFrequency(1);
@@ -121,11 +121,11 @@ void FGATCManager::init() {
             leg = 1;
             //double, lat, lon, head; // Unused variables;
             //int getId = apt->getDynamics()->getParking(gateId, &lat, &lon, &head);
-            aircraftRadius = pk->parking()->getRadius();
-            string fltType = pk->parking()->getType(); // gate / ramp, ga, etc etc.
+            aircraftRadius = pk.parking()->getRadius();
+            string fltType = pk.parking()->getType(); // gate / ramp, ga, etc etc.
             string aircraftType; // Unused.
             string airline;      // Currently used for gate selection, but a fallback mechanism will apply when not specified.
-            fp->setGate(*pk);
+            fp->setGate(pk);
             if (!(fp->createPushBack(&ai_ac,
                                      false,
                                      apt,