[osg-users] Crash when application closes if linking with OSG

Robert Osfield robert.osfield at gmail.com
Mon Oct 5 03:48:58 PDT 2015


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151005/f4eb7e02/attachment-0003.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: singletons.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151005/f4eb7e02/attachment-0003.bin>


More information about the osg-users mailing list