[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
&#10;  &lt;struct name=&quot;upperPositionLimits&quot; type=&quot;array&quot;&gt;&#10;     &lt;description&gt;Upper position limits (deg)&lt;/description&gt;&#10;     &lt;simple type=&quot;double&quot;&gt;&lt;value&gt;40&lt;/value&gt;&lt;/simple&gt; &#10;     &lt;simple type=&quot;double&quot;&gt;&lt;value&gt;40&lt;/value&gt;&lt;/simple&gt; &#10;  &lt;/struct&gt;&#10;

resulting at runtime in
&#10; Configuration Properties: &#10;      array upperPositionLimits = {46.8, 23.5}         (Upper position limits&#10;(deg))&#10;

and on exiting the deployer, part of orocos.log has
&#10;4.400 [ Info   ][PropertyLoader::save] Stage updating of file&#10;data/orocos/cpf/StageSim.cpf&#10;4.401 [ Info   ][PropertyLoader::save] Writing all properties of Stage to file&#10;data/orocos/cpf/StageSim.cpf&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double velocityLimit.&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;PropertyBag lowerPositionLimits.&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: created Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;PropertyBag upperPositionLimits.&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: created Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double .&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double dangerZoneSize.&#10;4.401 [ Debug  ][PropertyLoader::save] updateProperties: updating Property&#10;double warningZoneSize.&#10;4.401 [ Info   ][PropertyLoader::save] Wrote data/orocos/cpf/StageSim.cpf&#10;

and the final property file has
&#10;  &lt;struct name=&quot;upperPositionLimits&quot; type=&quot;array&quot;&gt;&#10;     &lt;description&gt;Upper position limits (deg)&lt;/description&gt;&#10;     &lt;simple name=&quot;upperPositionLimits&quot;&#10;type=&quot;double&quot;&gt;&lt;value&gt;40&lt;/value&gt;&lt;/simple&gt;&#10;     &lt;simple type=&quot;double&quot;&gt;&lt;value&gt;40&lt;/value&gt;&lt;/simple&gt;&#10;     &lt;simple type=&quot;double&quot;&gt;&lt;value&gt;40&lt;/value&gt;&lt;/simple&gt;&#10;  &lt;/struct&gt;&#10;
which our componet won't load back in as the array is of the wrong size
&#10;0.321 [ ERROR  ][DeploymentComponent::configureComponents] Size of property&#10;upperPositionLimits: 3 != 2&#10;

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