From 482a18b9f219f2e321a23cc69468a6938c2dc073 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 5 Jun 2009 11:48:35 +0000 Subject: [PATCH] Added depends_on template and usage in RenderBin to help with static variable destruction ordering --- include/osg/Referenced | 7 +++++++ src/osgUtil/RenderBin.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/osg/Referenced b/include/osg/Referenced index 782b9347e..e95b27037 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 e63d2763a..1ea40e8eb 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() {}