[Bug 737] New: Autosave adds unnecessary element when writing arrays

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737

Summary: Autosave adds unnecessary element when writing arrays
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P3
Component: Properties & XML
AssignedTo: orocos-dev [..] ...
ReportedBy: kiwi [dot] net [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Autosave of a std::vector<double> property of size 2, results in 3 elements
being written back to the property file.

Property file starts with

  <struct name="upperPositionLimits" type="array">
     <description>Upper position limits (deg)</description>
     <simple type="double"><value>40</value></simple> 
     <simple type="double"><value>40</value></simple> 
  </struct>

resulting at runtime in

 Configuration Properties: 
      array upperPositionLimits = {46.8, 23.5}         (Upper position limits
(deg))

and on exiting the deployer, part of orocos.log has

4.400 [ Info   ][PropertyLoader::save] Stage updating of file
data/orocos/cpf/StageSim.cpf
4.401 [ Info   ][PropertyLoader::save] Writing all properties of Stage to file
data/orocos/cpf/StageSim.cpf
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double velocityLimit.
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
PropertyBag lowerPositionLimits.
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: created Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
PropertyBag upperPositionLimits.
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: created Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double .
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double dangerZoneSize.
4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property
double warningZoneSize.
4.401 [ Info   ][PropertyLoader::save] Wrote data/orocos/cpf/StageSim.cpf

and the final property file has

  <struct name="upperPositionLimits" type="array">
     <description>Upper position limits (deg)</description>
     <simple name="upperPositionLimits"
type="double"><value>40</value></simple>
     <simple type="double"><value>40</value></simple>
     <simple type="double"><value>40</value></simple>
  </struct>

which our componet won't load back in as the array is of the wrong size
0.321 [ ERROR  ][DeploymentComponent::configureComponents] Size of property
upperPositionLimits: 3 != 2

Removing the description element from the initial property file has no effect.

Looking at the code, I can't find anything yet ...

[Bug 737] Autosave adds unnecessary element when writing arrays

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737

--- Comment #5 from Peter Soetens <peter [..] ...> 2009-11-30 16:40:12 ---
(In reply to comment #4)
> Fix pushed to all repos and 1.10 branch

Previous fix did not fix this issue. The bug was in the XML demarshallers (both
tiny & Xerces). New fix pushed to all repos and 1.10 branch.

Peter

[Bug 737] Autosave adds unnecessary element when writing arrays

On Nov 30, 2009, at 10:40 , Peter Soetens wrote:

> https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737
>
>
>
>
>
> --- Comment #5 from Peter Soetens <peter [..] ...> 2009-11-30 16:40:12 ---
> (In reply to comment #4)
>> Fix pushed to all repos and 1.10 branch
>
> Previous fix did not fix this issue. The bug was in the XML demarshallers (both
> tiny & Xerces). New fix pushed to all repos and 1.10 branch.
>
> Peter

Confirm this fixes the problem. Thanks! :-)

Also, the attached patch is now required for RTT. Didn't we fix this months ago? The problem is definitely in the SVN v1 repository.

Stephen

[Bug 737] Autosave adds unnecessary element when writing arrays

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737

Peter Soetens <peter [..] ...> changed:

What |Removed |Added
----------------------------------------------------------------------------
Resolution| |FIXED
Status|NEW |RESOLVED

--- Comment #4 from Peter Soetens <peter [..] ...> 2009-11-26 12:36:54 ---
Fix pushed to all repos and 1.10 branch

[Bug 737] Autosave adds unnecessary element when writing arrays

On Nov 26, 2009, at 06:36 , Peter Soetens wrote:

> https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737
>
>
> Peter Soetens <peter [..] ...> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Resolution| |FIXED
> Status|NEW |RESOLVED
>
>
>
>
> --- Comment #4 from Peter Soetens <peter [..] ...> 2009-11-26 12:36:54 ---
> Fix pushed to all repos and 1.10 branch

Unfortunately, the patch fails to fix the problem. :-(

Adding some debug output to the patch shows that "sources" always has one more element that "mines", no matter how many array elements are actually in the property file. This seems to cause the extra element to appear in the output. I had no luck backtracking from there ...

Stephen

[Bug 737] Autosave adds unnecessary element when writing arrays

On Mon, Nov 30, 2009 at 14:48, S Roderick <kiwi [dot] net [..] ...> wrote:
> On Nov 26, 2009, at 06:36 , Peter Soetens wrote:
>
>> https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737
>>
>>
>> Peter Soetens <peter [..] ...> changed:
>>
>>           What    |Removed                     |Added
>> ----------------------------------------------------------------------------
>>         Resolution|                            |FIXED
>>             Status|NEW                         |RESOLVED
>>
>>
>>
>>
>> --- Comment #4 from Peter Soetens <peter [..] ...>  2009-11-26 12:36:54 ---
>> Fix pushed to all repos and 1.10 branch
>
>
> Unfortunately, the patch fails to fix the problem. :-(
>
> Adding some debug output to the patch shows that "sources" always has one more element that "mines", no matter how many array elements are actually in the property file. This seems to cause the extra element to appear in the output. I had no luck backtracking from there ...

You're right. Looking into it...

Peter

[Bug 737] Autosave adds unnecessary element when writing arrays

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737

--- Comment #3 from Peter Soetens <peter [..] ...> 2009-11-26 12:34:45 ---
Created an attachment (id=575)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=575)
Fixes bug in updateProperties of RTT

The bug was caused by the wrong use of std::unique.

[Bug 737] Autosave adds unnecessary element when writing arrays

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737

--- Comment #1 from Peter Soetens <peter [..] ...> 2009-11-26 11:23:57 ---
Yep reproduced it.

[Bug 737] Autosave adds unnecessary element when writing arrays

https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=737

--- Comment #2 from Peter Soetens <peter [..] ...> 2009-11-26 11:51:42 ---
It's updateProperties that can't properly handle updating nameless properties
(although it tries). We can fix this function or emit named simple elements for
the array type.

I'm looking into updateProperties() for now.

Peter