diff --git a/include/osg/Referenced b/include/osg/Referenced index f851f3dbf..725746703 100644 --- a/include/osg/Referenced +++ b/include/osg/Referenced @@ -31,6 +31,13 @@ namespace osg { class DeleteHandler; class Observer; +/** template class to help enforce static initialization order. */ +template +struct depends_on +{ + depends_on() { M(); } +}; + /** Base class from providing referencing counted objects.*/ class OSG_EXPORT Referenced { diff --git a/src/osgUtil/RenderBin.cpp b/src/osgUtil/RenderBin.cpp index b33cafb19..99340fd06 100644 --- a/src/osgUtil/RenderBin.cpp +++ b/src/osgUtil/RenderBin.cpp @@ -26,8 +26,8 @@ using namespace osg; using namespace osgUtil; - -class RenderBinPrototypeList : public osg::Referenced, public std::map< std::string, osg::ref_ptr > +class RenderBinPrototypeList : osg::depends_on, + public osg::Referenced, public std::map< std::string, osg::ref_ptr > { public: RenderBinPrototypeList() {} @@ -83,8 +83,17 @@ void RenderBin::removeRenderBinPrototype(RenderBin* proto) RenderBinPrototypeList* list = renderBinPrototypeList(); if (list && proto) { - RenderBinPrototypeList::iterator itr = list->find(proto->className()); - if (itr != list->end()) list->erase(itr); + for(RenderBinPrototypeList::iterator itr = list->begin(); + itr != list->end(); + ++itr) + { + if (itr->second == proto) + { + // osg::notify(osg::NOTICE)<<"Found protype, now erasing "<first<erase(itr); + return; + } + } } }