]> git.mxchange.org Git - simgear.git/commitdiff
Ensure a reference on the cube map texture is always held
authorfredb <fredb>
Fri, 26 Jan 2007 20:30:02 +0000 (20:30 +0000)
committerfredb <fredb>
Fri, 26 Jan 2007 20:30:02 +0000 (20:30 +0000)
simgear/scene/model/shadanim.cxx

index cffae0ff97a3d7ecc8643db429dadbdbe286a519..b631c7d5c176e59f61ee092f7767d23b4d09bc8b 100644 (file)
@@ -126,14 +126,12 @@ private:
 static osg::TextureCubeMap*
 getOrCreateTextureCubeMap()
 {
-  static osg::TextureCubeMap* textureCubeMap = 0;
-  if (textureCubeMap)
-    return textureCubeMap;
+   static osg::ref_ptr<osg::TextureCubeMap> textureCubeMap;
 
   static SGMutex mutex;
   SGGuard<SGMutex> locker(mutex);
-  if (textureCubeMap)
-    return textureCubeMap;
+  if (textureCubeMap.get())
+    return textureCubeMap.get();
 
   // create and setup the texture object
   textureCubeMap = new osg::TextureCubeMap;
@@ -146,7 +144,7 @@ getOrCreateTextureCubeMap()
   
   textureCubeMap->setUpdateCallback(new SGMapGenCallback);
 
-  return textureCubeMap;
+  return textureCubeMap.get();
 }
 
 static void create_specular_highlights(osg::Node *node)