]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/makeEffect.cxx
Random buildings - initial commit.
[simgear.git] / simgear / scene / material / makeEffect.cxx
index 4ca288b87f5603dbcf8a9c11a50f0a53b7719e5b..06bf47b229b1d8d118816f85a3c60a2f63e41e53 100644 (file)
@@ -44,7 +44,7 @@ using namespace osg;
 using namespace effect;
 
 typedef vector<const SGPropertyNode*> RawPropVector;
-typedef map<const string, observer_ptr<Effect> > EffectMap;
+typedef map<const string, ref_ptr<Effect> > EffectMap;
 
 namespace
 {
@@ -206,10 +206,10 @@ Effect* makeEffect(SGPropertyNode* prop,
                     lock(effectMutex);
                 cache = parent->getCache();
                 itr = cache->find(key);
-                if (itr != cache->end()) {
-                    effect = itr->second.get();
-                    if (effect.valid())
-                        effect->generator = parent->generator;  // Copy the generators
+                if ((itr != cache->end())&&
+                    itr->second.lock(effect))
+                {
+                    effect->generator = parent->generator;  // Copy the generators
                 }
             }
             if (!effect.valid()) {
@@ -222,8 +222,8 @@ Effect* makeEffect(SGPropertyNode* prop,
                 pair<Effect::Cache::iterator, bool> irslt
                     = cache->insert(make_pair(key, effect));
                 if (!irslt.second) {
-                    ref_ptr<Effect> old = irslt.first->second.get();
-                    if (old.valid())
+                    ref_ptr<Effect> old;
+                    if (irslt.first->second.lock(old))
                         effect = old; // Another thread beat us in creating it! Discard our own...
                     else
                         irslt.first->second = effect; // update existing, but empty observer