diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 230837621..e307a1d83 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -145,7 +145,7 @@ FGAIBase::~FGAIBase() { model_removed->setStringValue(props->getPath()); } - if (_refID != 0 && _refID != 1) { + if (_fx && _refID != 0 && _refID != 1) { SGSoundMgr *smgr = globals->get_soundmgr(); stringstream name; name << "aifx:"; @@ -153,7 +153,8 @@ FGAIBase::~FGAIBase() { smgr->remove(name.str()); } - delete fp; + if (fp) + delete fp; fp = 0; } diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index f09a96e00..b4815c41a 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -230,7 +230,7 @@ private: bool _initialized; osg::ref_ptr _model; //The 3D model LOD object - FGAIModelData* _aimodel; + osg::ref_ptr _aimodel; string _fxpath; SGSharedPtr _fx;