Hi Rui,
I understand the motivation - to scope the change to the version
number, but don't feel it's an appropriate way to do it as it's not
immediately obvious how the macro works/how it's supposed to be used.
Instead I think it would be better to use C++ in more conventional way
w.r.t scoping and move version setting to within the block and use a
local proxy object, so have it thus:
ADD_USER_SERIALIZER( Descriptions )
{
UPDATE_TO_VERSION( 77 )
REMOVE_SERIALIZER( Descriptions )
}
ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL )
Perhaps having a new macro named a bit a proxy such as
LOCAL_UPDATE_TO_VERSION(77), or perhaps have a
PUSH_UPDATE_TO_VERSION(77) and corresponding POP_UPDATE_TO_VERSION()
would be appropriate to help clarify it's usage.
Robert.
On 8 October 2012 17:33, Wang Rui <[email protected]> wrote:
> Hi Robert,
>
> I made this fix because of seeing some wrappers using
> UPDATE_TO_VERSION in such ways:
>
> ADD_USER_SERIALIZER( Descriptions )
> UPDATE_TO_VERSION( 77 )
> {
> REMOVE_SERIALIZER( Descriptions )
> }
>
> ADD_OBJECT_SERIALIZER( StateSet, osg::StateSet, NULL )
>
> The first 5 lines are all right. But as UPDATE_TO_VERSION actually set
> the version state which will be kept until another UPDATE_TO_VERSION
> change it, so the StateSet serializer will also be limited as "above
> version 77". This makes lower version OSG unable to read its value
> again, but of course it should be able to do that.
>
> My fix may not be suitable as I just make it quickly without doing
> more changes to wrappers. An alternative method is to define a pair of
> BEGIN_WRAPPER_VERSION/END_WRAPPER_VERSION macros to replace such
> cases, and still keep UPDATE_TO_VERSION as it used to be. Do you think
> this will be proper?
>
> Wang Rui
>
>
> 2012/10/9 Robert Osfield <[email protected]>:
>> Hi Rui,
>>
>> I've reviewed the changes and don't find it immediately obvious how
>> the lttle for loop functions. I can't help but feel there is
>> potential for confusion as it's an implicit loop and will only work
>> appropriately if directly followed by an { .. } block and changes the
>> way the code works w.r.t previously.
>>
>> Robert.
>>
>> On 7 October 2012 03:30, Wang Rui <[email protected]> wrote:
>>> Hi Robert,
>>>
>>> This fixes a problem reported by Farshid in the thread "[osg-users]
>>> Backward compatibility with custom serializers". The macro
>>> UPDATE_TO_VERSION is used following with brackets as if it could
>>> update to specific version in a certain scope. But it actually changes
>>> the version STATE so all following serializers will be affected no
>>> matter it's in brackets or not. This patch fixes the confusing problem
>>> with a simple trick.
>>>
>>> Cheers,
>>>
>>> Wang Rui
>>>
>>> _______________________________________________
>>> osg-submissions mailing list
>>> [email protected]
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>>>
>> _______________________________________________
>> osg-submissions mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org