]> git.mxchange.org Git - simgear.git/commitdiff
Fix leak of object-mask textures
authorJames Turner <zakalawe@mac.com>
Thu, 13 Mar 2014 22:16:00 +0000 (22:16 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 13 Mar 2014 22:16:00 +0000 (22:16 +0000)
simgear/scene/material/mat.cxx
simgear/scene/material/mat.hxx

index 738dd5d028b01cb236664ee32468682e4c1a4fd7..2fe251049ddf684be099c5e0c5de172c36508aad 100644 (file)
@@ -237,7 +237,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
                 osg::Image* image = osgDB::readImageFile(fullMaskPath, options);
                 if (image && image->valid())
                 {
-                    osg::Texture2D* object_mask = new osg::Texture2D;
+                    Texture2DRef object_mask = new osg::Texture2D;
 
                     bool dds_mask = (ompath.lower_extension() == "dds");
 
@@ -485,7 +485,7 @@ osg::Texture2D* SGMaterial::get_object_mask(const SGTexturedTriangleBin& triangl
     // so we index based on the texture index, 
     unsigned int i = triangleBin.getTextureIndex() % _status.size();
     if (i < _masks.size()) {
-        return _masks[i];
+        return _masks[i].get();
     } else {
         return 0;
     }
index 7ed5958c962b17f7609ac572306cc45e96fe364c..c0a651327e43084722869c9e35cecde17a085889 100644 (file)
@@ -42,6 +42,9 @@ namespace osg
 class StateSet;
 }
 
+
+typedef osg::ref_ptr<osg::Texture2D> Texture2DRef;
+    
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/threads/SGThread.hxx> // for SGMutex
 #include <simgear/math/SGMath.hxx>
@@ -466,7 +469,7 @@ private:
   
   // Object mask, a simple RGB texture used as a mask when placing
   // random vegetation, objects and buildings
-  std::vector<osg::Texture2D*> _masks;
+  std::vector<Texture2DRef> _masks;
   
   // Condition, indicating when this material is active
   SGSharedPtr<const SGCondition> condition;