Hi David,

I have removed the InitRegistry proxy object from
src/osgViewer/ViewerBase.cpp and introduced OSG_INIT_SINGLETON_PROXY usage
in DatabasePager.cpp and Registry.cpp which should ensure that the
singleton's are initialized in a single threaded way and destructed in an
appropriate order.  I have checked this change into svn/trunk and the
OSG-3.4 branch. Changes are:

Index: src/osgDB/DatabasePager.cpp
===================================================================
--- src/osgDB/DatabasePager.cpp (revision 15130)
+++ src/osgDB/DatabasePager.cpp (working copy)
@@ -1236,6 +1236,8 @@
     return s_DatabasePager;
 }

+OSG_INIT_SINGLETON_PROXY(ProxyInitDatabasePager,
DatabasePager::prototype())
+
 DatabasePager* DatabasePager::create()
 {
     return DatabasePager::prototype().valid() ?
Index: src/osgDB/Registry.cpp
===================================================================
--- src/osgDB/Registry.cpp      (revision 15130)
+++ src/osgDB/Registry.cpp      (working copy)
@@ -214,7 +214,9 @@
     return s_registry.get(); // will return NULL on erase
 }

+OSG_INIT_SINGLETON_PROXY(ProxyInitRegistry, Registry::instance())

+
 // definition of the Registry
 Registry::Registry()
 {
Index: src/osgViewer/ViewerBase.cpp
===================================================================
--- src/osgViewer/ViewerBase.cpp        (revision 15142)
+++ src/osgViewer/ViewerBase.cpp        (working copy)
@@ -40,23 +40,6 @@

 using namespace osgViewer;

-
-struct InitRegistry
-{
-    InitRegistry()
-    {
-        osgDB::Registry::instance();
-    }
-
-    ~InitRegistry()
-    {
-        osgDB::DatabasePager::prototype() = 0;
-        osgDB::Registry::instance(true);
-    }
-};
-
-static InitRegistry s_InitRegistry;
-
 ViewerBase::ViewerBase():
     osg::Object(true)
 {

This patch is also attached, under unix you can apply this with:

  cd OpenSceneGraph
  patch -p0 < singletons.patch

Could you test this out and let me know if it works fine or not.

Cheers,
Robert.
Index: src/osgDB/DatabasePager.cpp
===================================================================
--- src/osgDB/DatabasePager.cpp	(revision 15130)
+++ src/osgDB/DatabasePager.cpp	(working copy)
@@ -1236,6 +1236,8 @@
     return s_DatabasePager;
 }
 
+OSG_INIT_SINGLETON_PROXY(ProxyInitDatabasePager, DatabasePager::prototype())
+
 DatabasePager* DatabasePager::create()
 {
     return DatabasePager::prototype().valid() ?
Index: src/osgDB/Registry.cpp
===================================================================
--- src/osgDB/Registry.cpp	(revision 15130)
+++ src/osgDB/Registry.cpp	(working copy)
@@ -214,7 +214,9 @@
     return s_registry.get(); // will return NULL on erase
 }
 
+OSG_INIT_SINGLETON_PROXY(ProxyInitRegistry, Registry::instance())
 
+
 // definition of the Registry
 Registry::Registry()
 {
Index: src/osgViewer/ViewerBase.cpp
===================================================================
--- src/osgViewer/ViewerBase.cpp	(revision 15142)
+++ src/osgViewer/ViewerBase.cpp	(working copy)
@@ -40,23 +40,6 @@
 
 using namespace osgViewer;
 
-
-struct InitRegistry
-{
-    InitRegistry()
-    {
-        osgDB::Registry::instance();
-    }
-
-    ~InitRegistry()
-    {
-        osgDB::DatabasePager::prototype() = 0;
-        osgDB::Registry::instance(true);
-    }
-};
-
-static InitRegistry s_InitRegistry;
-
 ViewerBase::ViewerBase():
     osg::Object(true)
 {
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to