Fix leak of object-mask textures
This commit is contained in:
parent
d44a3117d9
commit
966789de90
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user