From Wang Rui, "I modified the Serializer header to add a UPDATE_TO_VERSION_SCOPED
macro, which could set version within brackets and reset it after that. All related serializers are also modified so that the backward-compatibility bug reported by Farshid can be fixed. " From Robert Osfield, removed the use of osg::Referenced and creating the proxy object on the heap.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user