From 06e6883396fef04caf8e6c54d1874de2b5581644 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 14 Aug 2020 16:47:02 +0100 Subject: [PATCH] Call new simgear clearSharedTreeGeometry Should remove the Final Effect (TM) and fix one source of memory corruption on reset. --- src/Main/fg_init.cxx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 7d7a0bfd3..8c024b9f3 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -61,12 +61,13 @@ #include #include -#include -#include #include +#include +#include #include -#include +#include #include +#include #include #include @@ -1305,6 +1306,7 @@ void fgStartNewReset() flightgear::unregisterMainLoopProperties(); FGReplayData::resetStatisticsProperties(); + simgear::clearSharedTreeGeometry(); simgear::clearEffectCache(); simgear::SGModelLib::resetPropertyRoot(); simgear::GlobalParticleCallback::setSwitch(NULL); @@ -1316,6 +1318,18 @@ void fgStartNewReset() // otherwise channels are duplicated globals->get_channel_options_list()->clear(); + // IMPORTANT + // this is the low-water mark of the reset process. + // Subsystems (except the special ones), properties, OSG nodes, Effects + // should all be gone at this, except for special things, such as the + // splash node. + // From here onwards we're recreating early parts of main/init, before + // we restart the main loop. + // This is the place to check that instances of classes have all be + // cleaned up correctly. (Also, the OSG threads are all paused, we're back + // in single threaded mode) + ///////////////////// + flightgear::addons::AddonManager::createInstance(); fgInitConfig(0, NULL, true);