From 9dd487e6c860c07286b940ce07d8f28b9dc90158 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 2 Oct 2006 11:38:25 +0000 Subject: [PATCH] From Andreas Ekstrand, "Attached is a modified ReaderWriterDAE.cpp which creates the one and only DAE instance when it's first needed instead of in the constructor. This fixes the problem with osgdb_dae.dll not being loaded due to unwanted ordering of global initialization. This fix and the previous fix of the COLLADA plugin might be unnecessary with the latest COLLADA DOM, but since many of us will probably still use the older version of the DOM, I guess it's better this way. " --- src/osgPlugins/dae/ReaderWriterDAE.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/dae/ReaderWriterDAE.cpp b/src/osgPlugins/dae/ReaderWriterDAE.cpp index 2d210af5c..d98736372 100644 --- a/src/osgPlugins/dae/ReaderWriterDAE.cpp +++ b/src/osgPlugins/dae/ReaderWriterDAE.cpp @@ -29,9 +29,8 @@ class ReaderWriterDAE : public osgDB::ReaderWriter { public: - ReaderWriterDAE() + ReaderWriterDAE() : dae_(NULL) { - dae_ = new DAE(); } ~ReaderWriterDAE() @@ -74,6 +73,9 @@ ReaderWriterDAE::readNode(const std::string& fname, osg::notify(osg::INFO) << "ReaderWriterDAE( \"" << fileName << "\" )" << std::endl; + if (dae_ == NULL) + const_cast(this)->dae_ = new DAE(); + osgdae::daeReader daeReader(dae_); std::string fileURI( osgDB::convertFileNameToUnixStyle(fileName) ); if ( ! daeReader.convert( fileURI ) ) @@ -117,6 +119,9 @@ ReaderWriterDAE::writeNode( const osg::Node& node, } } + if (dae_ == NULL) + const_cast(this)->dae_ = new DAE(); + osgdae::daeWriter daeWriter(dae_, fname, usePolygon ); daeWriter.setRootNode( node ); const_cast(&node)->accept( daeWriter );