From 6849311d495267204a87ea352c070fb9a442df26 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 20 Mar 2020 18:43:12 +0000 Subject: [PATCH] Own the SGReaderWriterOptions object Prevents it being unintentionally freed during the read call, causing a crash depending on the OSG version (some versions take a kung-fu death grip) --- src/Viewer/splash.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Viewer/splash.cxx b/src/Viewer/splash.cxx index 6fc8cf6dc..467af2fb8 100644 --- a/src/Viewer/splash.cxx +++ b/src/Viewer/splash.cxx @@ -60,6 +60,8 @@ static const char* LICENSE_URL_TEXT = "Licensed under the GNU GPL. See http://www.flightgear.org for more information"; +using namespace simgear; + class SplashScreenUpdateCallback : public osg::NodeCallback { public: virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) @@ -87,10 +89,9 @@ void SplashScreen::createNodes() #if OSG_VERSION_LESS_THAN(3,4,0) _splashImage = osgDB::readImageFile(splashImage); #else - auto staticOptions = simgear::SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); - staticOptions->setLoadOriginHint(simgear::SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); + osg::ref_ptr staticOptions = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); + staticOptions->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); _splashImage = osgDB::readRefImageFile(splashImage, staticOptions); -// _splashImage = osgDB::readRefImageFile(selectSplashImage()); #endif if (!_splashImage){