From 2b1336cd39bc1dd08d031dde80411654063d0ef9 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Sat, 28 Jan 2017 23:07:23 +0000 Subject: [PATCH] clear GroundLightManager also on non-standard exits to avoid crash (e.g. --show-aircraft, https://sourceforge.net/p/flightgear/codetickets/1935/ ) --- src/Main/bootstrap.cxx | 5 +++++ src/Main/main.cxx | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index e0ade22dd..73f0f79ba 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -310,6 +311,10 @@ void fgExitCleanup() { // on the common exit path globals is already deleted, and NULL, // so this only happens on error paths. delete globals; + // avoid crash on exit (https://sourceforge.net/p/flightgear/codetickets/1935/) + simgear::GroundLightManager::instance()->getRunwayLightStateSet()->clear(); + simgear::GroundLightManager::instance()->getTaxiLightStateSet()->clear(); + simgear::GroundLightManager::instance()->getGroundLightStateSet()->clear(); simgear::shutdownLogging(); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 2e7997e81..4f3b37128 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -55,7 +55,6 @@ extern bool global_crashRptEnabled; #include #include #include -#include #include #include @@ -555,9 +554,6 @@ int fgMainInit( int argc, char **argv ) // delete the NavCache here. This will cause the destruction of many cached // objects (eg, airports, navaids, runways). delete flightgear::NavDataCache::instance(); - simgear::GroundLightManager::instance()->getRunwayLightStateSet()->clear(); - simgear::GroundLightManager::instance()->getTaxiLightStateSet()->clear(); - simgear::GroundLightManager::instance()->getGroundLightStateSet()->clear(); return result; }