From: ThorstenB Date: Sun, 18 Nov 2012 16:20:11 +0000 (+0100) Subject: Remove static subsystem dependencies X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=be3f94f63a35b25f14642cc5c4c8dac34b0ffec6;p=flightgear.git Remove static subsystem dependencies preventing us from recreating subsystems on reset/reinit. --- diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index 3ebaf29e2..98aaba6f9 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -257,10 +257,7 @@ FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const FGRunway* FGAirport::getActiveRunwayForUsage() const { - static FGEnvironmentMgr* envMgr = NULL; - if (!envMgr) { - envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment"); - } + FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment"); // This forces West-facing rwys to be used in no-wind situations // which is consistent with Flightgear's initial setup. diff --git a/src/Main/main.cxx b/src/Main/main.cxx index f8b0fe0aa..50b1bb026 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -76,6 +76,7 @@ using std::vector; extern int _bootstrap_OSInit; static SGPropertyNode_ptr frame_signal; +static TimeManager* timeMgr; // What should we do when we have nothing else to do? Let's get ready // for the next move and update the display? @@ -89,7 +90,6 @@ static void fgMainLoop( void ) // compute simulated time (allowing for pause, warp, etc) and // real elapsed time double sim_dt, real_dt; - static TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time"); timeMgr->computeTimeDeltas(sim_dt, real_dt); // update all subsystems @@ -101,6 +101,14 @@ static void fgMainLoop( void ) } +static void registerMainLoop() +{ + // stash current frame signal property + frame_signal = fgGetNode("/sim/signals/frame", true); + timeMgr = (TimeManager*) globals->get_subsystem("time"); + fgRegisterIdleHandler( fgMainLoop ); +} + // This is the top level master main function that is registered as // our idle function @@ -263,9 +271,7 @@ static void fgIdleFunction ( void ) { // We've finished all our initialization steps, from now on we // run the main loop. fgSetBool("sim/sceneryloaded", false); - // stash current frame signal property - frame_signal = fgGetNode("/sim/signals/frame", true); - fgRegisterIdleHandler( fgMainLoop ); + registerMainLoop(); } }