From 8e57a61aed437f75b8af7df60c18e26b877a4e7d Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Sun, 20 Jan 2019 18:08:34 +0100 Subject: [PATCH] Fix null ref during load. This happened a few times --- simgear/scene/sky/cloud.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index 3c03c514..89a964b7 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -485,9 +485,11 @@ SGCloudLayer::rebuild() // repaint the cloud layer colors bool SGCloudLayer::repaint( const SGVec3f& fog_color ) { osg::Vec4f combineColor(toOsg(fog_color), cloud_alpha); - osg::TexEnvCombine* combiner - = dynamic_cast(layer_root->getStateSet() - ->getTextureAttribute(1, osg::StateAttribute::TEXENV)); + osg::StateAttribute* textureAtt = layer_root->getStateSet()->getTextureAttribute(1, osg::StateAttribute::TEXENV); + osg::TexEnvCombine* combiner = dynamic_cast(textureAtt); + + if (combiner == nullptr) + return false; combiner->setConstantColor(combineColor); // Set the fog color for the 3D clouds too.