Hi,

I just looked over last night's email and realized what I wrote is about as 
clear as mud.

The problem is this: when the build options are read from disk by the 
readOptionalLayerSet method in BuildOptionsIO a leading empty string is 
retrieved from the stream resulting in an optional layer being added (which 
doesn't exist in the original file) with an empty name.

Cheers,

Brad

-----Original Message-----
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Christiansen, 
Brad
Sent: Friday, 25 June 2010 1:14 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] New problem with VPB serializer

Hi,

I have tracked down the issue further and have attached a 'fix' for the 
problem. My code change does seem to work but it is clearly not the correct 
solution. Wang Rui (or somebody else familiar with the new serialization), I am 
hoping that you will be able to point in the in direction of a proper fix as I 
am now stuck (and it is way past my bedtime :  ).

The old code was:

static bool readOptionalLayerSet( osgDB::InputStream& is, vpb::BuildOptions& bo 
) {
    vpb::BuildOptions::OptionalLayerSet& ols = bo.getOptionalLayerSet();
    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i  )
    {
        std::string value;
        is.readWrappedString( value );
        ols.insert(value);
    }
    is >> osgDB::END_BRACKET;
    return true;
}

and my 'fix; is:

static bool readOptionalLayerSet( osgDB::InputStream& is, vpb::BuildOptions& bo 
) {
    vpb::BuildOptions::OptionalLayerSet& ols = bo.getOptionalLayerSet();
    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
    ++size; //new
    for ( unsigned int i=0; i<size; ++i  )
    {
        std::string value;
        is.readWrappedString( value );
          if(!value.empty()) { //new
          ols.insert(value);
          } //new
    }
    is >> osgDB::END_BRACKET;
    return true;
}

Cheers,

Brad

-----Original Message-----
From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Christiansen, 
Brad
Sent: Friday, 25 June 2010 12:40 AM
To: OpenSceneGraph Users
Subject: [osg-users] New problem with VPB serializer

Hi,

I have just tracked down another issue with the VPB serializer. This time the 
issue arises when you try to add an optional layer (nb: this fails at an 
earlier point with the code in trunk at the moment, I will be submitting a fix 
for that tomorrow, though the issue can be demonstrated without it).

When build options that contain an optional layer are serialized an empty entry 
is added to the list.
e.g.

OptionalLayerSet 2 {
  ""
  "AnOptionalLayerName"
} 

I believe the bug is in BuildOptionsIO.cpp, probably in the SetSerializer 
class, thought I haven't managed to track it down exactly yet.

The attached files can be used to reproduce the error.
original.source is a copy of the build_master.source that was written out when 
I tried to add an optional set.

If you run:
 osgdem -s original.source --so original_resaved.source an error will be 
produced as the file cannot be read.

I have also attached 'fixed.source'. This has had the "" removed (note that the 
number of items in the set is still set to 2). This file can be de-serialized 
and then re-serialized but the result has the extra "" included. This can be 
done by running:
osgdem -s fixed.source --so fixed_result.source

Cheers,

Brad



DISCLAIMER:---------------------------------------------------------------------------
This e-mail transmission and any documents, files and previous e-mail messages 
attached to it are private and confidential. They may contain proprietary or 
copyright material or information that is subject to legal professional 
privilege. They are for the use of the intended recipient only.  Any 
unauthorised viewing, use, disclosure, copying, alteration, storage or 
distribution of, or reliance on, this message is strictly prohibited. No part 
may be reproduced, adapted or transmitted without the written permission of the 
owner. If you have received this transmission in error, or are not an 
authorised recipient, please immediately notify the sender by return email, 
delete this message and all copies from your e-mail system, and destroy any 
printed copies. Receipt by anyone other than the intended recipient should not 
be deemed a waiver of any privilege or protection. Thales Australia does not 
warrant or represent that this e-mail or any documents, files and previous 
e-mail mess
 ages attached are error or virus free.
--------------------------------------------------------------------------------------




DISCLAIMER:---------------------------------------------------------------------------
This e-mail transmission and any documents, files and previous e-mail messages 
attached to it are private and confidential. They may contain proprietary or 
copyright material or information that is subject to legal professional 
privilege. They are for the use of the intended recipient only.  Any 
unauthorised viewing, use, disclosure, copying, alteration, storage or 
distribution of, or reliance on, this message is strictly prohibited. No part 
may be reproduced, adapted or transmitted without the written permission of the 
owner. If you have received this transmission in error, or are not an 
authorised recipient, please immediately notify the sender by return email, 
delete this message and all copies from your e-mail system, and destroy any 
printed copies. Receipt by anyone other than the intended recipient should not 
be deemed a waiver of any privilege or protection. Thales Australia does not 
warrant or represent that this e-mail or any documents, files and previous 
e-mail mess
 ages attached are error or virus free.
--------------------------------------------------------------------------------------




DISCLAIMER:---------------------------------------------------------------------------
This e-mail transmission and any documents, files and previous e-mail messages
attached to it are private and confidential. They may contain proprietary or 
copyright
material or information that is subject to legal professional privilege. They 
are for
the use of the intended recipient only.  Any unauthorised viewing, use, 
disclosure,
copying, alteration, storage or distribution of, or reliance on, this message is
strictly prohibited. No part may be reproduced, adapted or transmitted without 
the
written permission of the owner. If you have received this transmission in 
error, or
are not an authorised recipient, please immediately notify the sender by return 
email,
delete this message and all copies from your e-mail system, and destroy any 
printed
copies. Receipt by anyone other than the intended recipient should not be 
deemed a
waiver of any privilege or protection. Thales Australia does not warrant or 
represent
that this e-mail or any documents, files and previous e-mail messages attached 
are
error or virus free.
--------------------------------------------------------------------------------------

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to