Introduced depend_on template and usage in RenderBin.cpp's singleton to solve crash on exit in static builds.
This commit is contained in:
@@ -31,6 +31,13 @@ namespace osg {
|
||||
class DeleteHandler;
|
||||
class Observer;
|
||||
|
||||
/** template class to help enforce static initialization order. */
|
||||
template <typename T, T M()>
|
||||
struct depends_on
|
||||
{
|
||||
depends_on() { M(); }
|
||||
};
|
||||
|
||||
/** Base class from providing referencing counted objects.*/
|
||||
class OSG_EXPORT Referenced
|
||||
{
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
|
||||
|
||||
class RenderBinPrototypeList : public osg::Referenced, public std::map< std::string, osg::ref_ptr<RenderBin> >
|
||||
class RenderBinPrototypeList : osg::depends_on<OpenThreads::Mutex*, osg::Referenced::getGlobalReferencedMutex>,
|
||||
public osg::Referenced, public std::map< std::string, osg::ref_ptr<RenderBin> >
|
||||
{
|
||||
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 "<<itr->first<<std::endl;
|
||||
list->erase(itr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user