diff --git a/include/osgFX/Registry b/include/osgFX/Registry index cb532d9da..a504a2281 100644 --- a/include/osgFX/Registry +++ b/include/osgFX/Registry @@ -31,10 +31,17 @@ namespace osgFX public: struct Proxy { - Proxy(const Effect* effect) + Proxy(const Effect* effect): _effect(effect) { Registry::instance()->registerEffect(effect); } + + ~Proxy() + { + Registry::instance()->removeEffect(_effect.get()); + } + private: + osg::ref_ptr _effect; }; typedef std::map > EffectMap; @@ -43,6 +50,8 @@ namespace osgFX inline void registerEffect(const Effect* effect); + inline void removeEffect(const Effect* effect); + inline const EffectMap& getEffectMap() const; protected: @@ -69,6 +78,15 @@ namespace osgFX _effects[effect->effectName()] = effect; } + inline void Registry::removeEffect(const Effect* effect) + { + EffectMap::iterator itr = _effects.find(effect->effectName()); + if (itr != _effects.end()) + { + _effects.erase(itr); + } + } + } #endif