]> git.mxchange.org Git - flightgear.git/commitdiff
Fix memory leak with FGAIModelData.
authorThorstenB <brehmt@gmail.com>
Fri, 9 Dec 2011 16:03:14 +0000 (17:03 +0100)
committerThorstenB <brehmt@gmail.com>
Fri, 9 Dec 2011 16:03:14 +0000 (17:03 +0100)
Be lazy and use ref pointers - to remove memory automatically.

src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx

index 230837621f32712504766c46d63a61255cdd315b..e307a1d83c1e3b75d698e32289585d9a794b9974 100644 (file)
@@ -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;
 }
 
index f09a96e00fee8cbe8cf68afec0a40cee8cbc1fad..b4815c41ad3b57dc5b4d9c2eca01bb99f336a79b 100644 (file)
@@ -230,7 +230,7 @@ private:
     bool _initialized;
     osg::ref_ptr<osg::LOD> _model; //The 3D model LOD object
 
-    FGAIModelData* _aimodel;
+    osg::ref_ptr<FGAIModelData> _aimodel;
 
     string _fxpath;
     SGSharedPtr<FGFX>  _fx;