#717: Disabling advanced weather crashes the sim

Protect from a NULL-pointer segfault in SGCloudField::removeCloudFromTree
when disabling advanced weather (may just fix a symptom).
This commit is contained in:
ThorstenB 2012-04-25 21:08:37 +02:00
parent 6e0e74a7d9
commit dd54f6938e

View File

@ -178,7 +178,7 @@ SGCloudField::SGCloudField() :
}
SGCloudField::~SGCloudField() {
}
}
void SGCloudField::clear(void) {
@ -208,7 +208,7 @@ void SGCloudField::applyVisAndLoDRange(void)
bool SGCloudField::addCloud(float lon, float lat, float alt, int index, osg::ref_ptr<EffectGeode> geode) {
return addCloud(lon, lat, alt, 0.0f, 0.0f, index, geode);
}
}
bool SGCloudField::addCloud(float lon, float lat, float alt, float x, float y, int index, osg::ref_ptr<EffectGeode> geode) {
// If this cloud index already exists, don't replace it.
@ -220,11 +220,16 @@ bool SGCloudField::addCloud(float lon, float lat, float alt, float x, float y, i
addCloudToTree(transform, lon, lat, alt, x, y);
cloud_hash[index] = transform;
return true;
}
}
// Remove a give cloud from inside the tree, without removing it from the cloud hash
void SGCloudField::removeCloudFromTree(osg::ref_ptr<osg::PositionAttitudeTransform> transform)
{
if (transform == 0)
{
// Ooops!
return;
}
osg::ref_ptr<osg::Group> lodnode = transform->getParent(0);
lodnode->removeChild(transform);
cloudcount--;