1
0
Fork 0

Reduces crashes after reset

Ensure the Pager doesn't hold onto a stale request.
This commit is contained in:
James Turner 2021-07-29 17:54:17 +01:00
parent b01beac664
commit df98d54948

View file

@ -1217,6 +1217,20 @@ void fgStartNewReset()
fgSetBool("/sim/signals/reinit", true);
fgSetBool("/sim/freeze/master", true);
// pause the osgDB requests right now, but more may appear; we will
// clear and cancel further down once shutdown has occured
FGRenderer* render = globals->get_renderer();
auto pager = render->getView()->getDatabasePager();
pager->setAcceptNewDatabaseRequests(false);
pager->cancel();
// extra clear is needed to ensure compile/merge lists are also empty
pager->clear();
assert(pager->getDataToMergeListSize() == 0);
assert(pager->getDataToCompileListSize() == 0);
SGSubsystemMgr* subsystemManger = globals->get_subsystem_mgr();
// Nasal is added in fgPostInit, ensure it's already shutdown
// before other subsystems, so Nasal listeners don't fire during shutdown
@ -1258,7 +1272,6 @@ void fgStartNewReset()
// drop any references to AI objects with TACAN
flightgear::NavDataCache::instance()->clearDynamicPositioneds();
FGRenderer* render = globals->get_renderer();
// needed or we crash in multi-threaded OSG mode
render->getViewerBase()->stopThreading();
@ -1275,10 +1288,6 @@ void fgStartNewReset()
FGScenery::getPagerSingleton()->clearRequests();
flightgear::CameraGroup::setDefault(NULL);
// don't cancel the pager until after shutdown, since AIModels (and
// potentially others) can queue delete requests on the pager.
render->getView()->getDatabasePager()->cancel();
render->getView()->getDatabasePager()->clear();
osgDB::Registry::instance()->clearObjectCache();
// Pager requests depend on this, so don't clear it until now
@ -1370,7 +1379,8 @@ void fgStartNewReset()
sgUserDataInit( globals->get_props() );
if (composite_viewer) {
composite_viewer_view->getDatabasePager()->setUpThreads(20, 1);
composite_viewer_view->getDatabasePager()->setUpThreads(2, 1);
composite_viewer_view->getDatabasePager()->setAcceptNewDatabaseRequests(true);
flightgear::CameraGroup::buildDefaultGroup(composite_viewer_view);
composite_viewer_view->setFrameStamp(composite_viewer->getFrameStamp());
composite_viewer_view->setDatabasePager(FGScenery::getPagerSingleton());
@ -1381,7 +1391,8 @@ void fgStartNewReset()
composite_viewer->startThreading();
}
else {
viewer->getDatabasePager()->setUpThreads(20, 1);
viewer->getDatabasePager()->setUpThreads(2, 1);
viewer->getDatabasePager()->setAcceptNewDatabaseRequests(true);
// must do this before preinit for Rembrandthe
flightgear::CameraGroup::buildDefaultGroup(viewer.get());
render->preinit();