diff --git a/src/Viewer/fgviewer.cxx b/src/Viewer/fgviewer.cxx index 2d7af1495..be10d7a64 100644 --- a/src/Viewer/fgviewer.cxx +++ b/src/Viewer/fgviewer.cxx @@ -226,5 +226,11 @@ fgviewerMain(int argc, char** argv) // pass the loaded scene graph to the viewer. viewer.setSceneData(loadedModel.get()); - return viewer.run(); + int result = viewer.run(); + + // clear cache now, since it contains SimGear objects. Otherwise SG_LOG + // calls during shutdown will cause crashes. + osgDB::Registry::instance()->clearObjectCache(); + + return result; } diff --git a/utils/fgviewer/fgviewer.cxx b/utils/fgviewer/fgviewer.cxx index f5bb8e944..e0ebcf250 100644 --- a/utils/fgviewer/fgviewer.cxx +++ b/utils/fgviewer/fgviewer.cxx @@ -188,6 +188,7 @@ main(int argc, char** argv) SG_LOG(SG_GENERAL, SG_ALERT, "Problems loading FlightGear materials.\n" << "Probably FG_ROOT is not properly set."); } + ml->refreshActiveMaterials(); simgear::SGModelLib::init(fg_root, props); // Set up the reader/writer options