diff --git a/include/osgDB/ObjectWrapper b/include/osgDB/ObjectWrapper index 91f057c1d..99f0b36e9 100644 --- a/include/osgDB/ObjectWrapper +++ b/include/osgDB/ObjectWrapper @@ -50,7 +50,9 @@ public: ObjectWrapper( osg::Object* proto, const std::string& name, const std::string& associates ); + void setUpdatedVersion( int ver ) { _version = ver; } + int getUpdatedVersion() const { return _version; } const osg::Object* getProto() const { return _proto.get(); } const std::string& getName() const { return _name; } @@ -83,6 +85,23 @@ protected: int _version; // Last updated version of the wrapper }; +struct UpdateWrapperVersionProxy +{ + UpdateWrapperVersionProxy( ObjectWrapper* w, int v ): _wrapper(w) + { + _lastVersion = w->getUpdatedVersion(); + w->setUpdatedVersion(v); + } + + ~UpdateWrapperVersionProxy() + { + _wrapper->setUpdatedVersion(_lastVersion); + } + + ObjectWrapper* _wrapper; + int _lastVersion; +}; + class Registry; class OSGDB_EXPORT ObjectWrapperManager : public osg::Referenced diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index 2d66721f9..28349d55a 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -977,6 +977,9 @@ public: #define UPDATE_TO_VERSION(VER) \ wrapper->setUpdatedVersion( (VER) ); +#define UPDATE_TO_VERSION_SCOPED(VER) \ + osgDB::UpdateWrapperVersionProxy uwvp(wrapper, (VER)); + #define REMOVE_SERIALIZER(PROP) \ wrapper->markSerializerAsRemoved( #PROP ); diff --git a/src/osgWrappers/serializers/osg/Node.cpp b/src/osgWrappers/serializers/osg/Node.cpp index f11c6a1f2..4fa744061 100644 --- a/src/osgWrappers/serializers/osg/Node.cpp +++ b/src/osgWrappers/serializers/osg/Node.cpp @@ -79,8 +79,8 @@ REGISTER_OBJECT_WRAPPER( Node, ADD_HEXINT_SERIALIZER( NodeMask, 0xffffffff ); // _nodeMask ADD_USER_SERIALIZER( Descriptions ); // _descriptions, deprecated - UPDATE_TO_VERSION( 77 ) { + UPDATE_TO_VERSION_SCOPED( 77 ) REMOVE_SERIALIZER( Descriptions ); } diff --git a/src/osgWrappers/serializers/osg/Object.cpp b/src/osgWrappers/serializers/osg/Object.cpp index 56526bbc5..d2a068807 100644 --- a/src/osgWrappers/serializers/osg/Object.cpp +++ b/src/osgWrappers/serializers/osg/Object.cpp @@ -42,9 +42,8 @@ REGISTER_OBJECT_WRAPPER( Object, END_ENUM_SERIALIZER(); // _dataVariance ADD_USER_SERIALIZER( UserData ); // _userData, deprecated - - UPDATE_TO_VERSION( 77 ) { + UPDATE_TO_VERSION_SCOPED( 77 ) REMOVE_SERIALIZER( UserData ); ADD_OBJECT_SERIALIZER( UserDataContainer, osg::UserDataContainer, NULL ); } diff --git a/src/osgWrappers/serializers/osg/PagedLOD.cpp b/src/osgWrappers/serializers/osg/PagedLOD.cpp index 149771509..b91ee6e10 100644 --- a/src/osgWrappers/serializers/osg/PagedLOD.cpp +++ b/src/osgWrappers/serializers/osg/PagedLOD.cpp @@ -145,8 +145,8 @@ REGISTER_OBJECT_WRAPPER( PagedLOD, ADD_USER_SERIALIZER( RangeDataList ); // _perRangeDataList ADD_USER_SERIALIZER( Children ); // _children (which are not loaded from external) - UPDATE_TO_VERSION( 70 ) { + UPDATE_TO_VERSION_SCOPED( 70 ) REMOVE_SERIALIZER( FrameNumberOfLastTraversal ); } diff --git a/src/osgWrappers/serializers/osgText/Text3D.cpp b/src/osgWrappers/serializers/osgText/Text3D.cpp index ac70b30fd..2c41b5655 100644 --- a/src/osgWrappers/serializers/osgText/Text3D.cpp +++ b/src/osgWrappers/serializers/osgText/Text3D.cpp @@ -15,8 +15,8 @@ REGISTER_OBJECT_WRAPPER( osgText_Text3D, ADD_ENUM_VALUE( PER_GLYPH ); END_ENUM_SERIALIZER(); // _renderMode - UPDATE_TO_VERSION( 68 ) { + UPDATE_TO_VERSION_SCOPED( 68 ) ADD_VEC4_SERIALIZER( Color, osg::Vec4(1.0,1.0,1.0,1.0) ); // _color } } diff --git a/src/osgWrappers/serializers/osgVolume/Locator.cpp b/src/osgWrappers/serializers/osgVolume/Locator.cpp index 6f92d3c45..1ec24b0d5 100644 --- a/src/osgWrappers/serializers/osgVolume/Locator.cpp +++ b/src/osgWrappers/serializers/osgVolume/Locator.cpp @@ -42,8 +42,8 @@ REGISTER_OBJECT_WRAPPER( osgVolume_Locator, ADD_MATRIXD_SERIALIZER( Transform, osg::Matrixd() ); // _transform ADD_USER_SERIALIZER( LocatorCallbacks ); - UPDATE_TO_VERSION( 90 ) { + UPDATE_TO_VERSION_SCOPED( 90 ) REMOVE_SERIALIZER( LocatorCallbacks ); } } diff --git a/src/osgWrappers/serializers/osgVolume/VolumeTile.cpp b/src/osgWrappers/serializers/osgVolume/VolumeTile.cpp index 691ab874c..c6ed859ac 100644 --- a/src/osgWrappers/serializers/osgVolume/VolumeTile.cpp +++ b/src/osgWrappers/serializers/osgVolume/VolumeTile.cpp @@ -28,8 +28,8 @@ REGISTER_OBJECT_WRAPPER( osgVolume_VolumeTile, "osg::Object osg::Node osg::Group osgVolume::VolumeTile" ) { ADD_OBJECT_SERIALIZER( Volume, osgVolume::Volume, NULL ); // _volume - UPDATE_TO_VERSION( 90 ) { + UPDATE_TO_VERSION_SCOPED( 90 ) REMOVE_SERIALIZER( Volume ); }