1
0
Fork 0

Fix memory leak with FGAIModelData.

Be lazy and use ref pointers - to remove memory automatically.
This commit is contained in:
ThorstenB 2011-12-09 17:03:14 +01:00
parent 84b31e573c
commit bfb0619f76
2 changed files with 4 additions and 3 deletions

View file

@ -145,7 +145,7 @@ FGAIBase::~FGAIBase() {
model_removed->setStringValue(props->getPath()); model_removed->setStringValue(props->getPath());
} }
if (_refID != 0 && _refID != 1) { if (_fx && _refID != 0 && _refID != 1) {
SGSoundMgr *smgr = globals->get_soundmgr(); SGSoundMgr *smgr = globals->get_soundmgr();
stringstream name; stringstream name;
name << "aifx:"; name << "aifx:";
@ -153,7 +153,8 @@ FGAIBase::~FGAIBase() {
smgr->remove(name.str()); smgr->remove(name.str());
} }
delete fp; if (fp)
delete fp;
fp = 0; fp = 0;
} }

View file

@ -230,7 +230,7 @@ private:
bool _initialized; bool _initialized;
osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object
FGAIModelData* _aimodel; osg::ref_ptr<FGAIModelData> _aimodel;
string _fxpath; string _fxpath;
SGSharedPtr<FGFX> _fx; SGSharedPtr<FGFX> _fx;