1
0
Fork 0

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)
This commit is contained in:
James Turner 2020-03-20 18:43:12 +00:00
parent 162ba266d0
commit 6849311d49

View file

@ -60,6 +60,8 @@
static const char* LICENSE_URL_TEXT = "Licensed under the GNU GPL. See http://www.flightgear.org for more information"; 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 { class SplashScreenUpdateCallback : public osg::NodeCallback {
public: public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
@ -87,10 +89,9 @@ void SplashScreen::createNodes()
#if OSG_VERSION_LESS_THAN(3,4,0) #if OSG_VERSION_LESS_THAN(3,4,0)
_splashImage = osgDB::readImageFile(splashImage); _splashImage = osgDB::readImageFile(splashImage);
#else #else
auto staticOptions = simgear::SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); osg::ref_ptr<SGReaderWriterOptions> staticOptions = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions());
staticOptions->setLoadOriginHint(simgear::SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN); staticOptions->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_SPLASH_SCREEN);
_splashImage = osgDB::readRefImageFile(splashImage, staticOptions); _splashImage = osgDB::readRefImageFile(splashImage, staticOptions);
// _splashImage = osgDB::readRefImageFile(selectSplashImage());
#endif #endif
if (!_splashImage){ if (!_splashImage){