Bug 279398 - Okteta structure tool: Array of dynamic sized elements, all elements get size of first element
Summary: Okteta structure tool: Array of dynamic sized elements, all elements get size...
Status: RESOLVED FIXED
Alias: None
Product: okteta
Classification: Applications
Component: Structures Tool (show other bugs)
Version: 0.7.0
Platform: Ubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: Alex Richardson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-04 17:19 UTC by Wolfgang Wallner
Modified: 2011-08-13 20:53 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot showing that all array-elements get the same size, while their size-elements would be different. (85.99 KB, image/png)
2011-08-04 17:19 UTC, Wolfgang Wallner
Details
Example for a CDC file matching the XML description. (1.01 KB, application/octet-stream)
2011-08-04 17:24 UTC, Wolfgang Wallner
Details
Screenshot of the CDC file structure. (75.27 KB, image/png)
2011-08-04 17:26 UTC, Wolfgang Wallner
Details
*.desktop file I used for my testcase (477 bytes, text/plain)
2011-08-04 17:29 UTC, Wolfgang Wallner
Details
*.osd file I used for my testcase (483 bytes, text/xml)
2011-08-04 17:31 UTC, Wolfgang Wallner
Details
A correspongin JavaScript structure definition (1.43 KB, application/javascript)
2011-08-09 12:04 UTC, Alex Richardson
Details
The desktop file used (481 bytes, application/x-desktop)
2011-08-09 12:05 UTC, Alex Richardson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Wallner 2011-08-04 17:19:31 UTC
Created attachment 62545 [details]
Screenshot showing that all array-elements get the same size, while their size-elements would be different.

Version:           0.7.0 (using KDE 4.7.0) 
OS:                Linux

I tried to use the structures tool to inspect an array of elements of dynamic size. This means, each array-element has its own size member, that specifies its size. However, only the size member of the first array-element is used. All other array-elements get the same size as the first one.



Reproducible: Always

Steps to Reproduce:
Create a structure template that contains an array, where each array element contains a size-member, and a member with dynamic size.

I used the following template to inspect CDC files ("Concise Device Configuration", a binary configuration file format used by Ethernet Powerlink):

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <struct name="CdcFile">
        <primitive name="NumberOfEntries" type="UInt32" />
        <array name="CdcEntries" length="10" >
            <struct name="nested">
                    <primitive name="Index" type="UInt16" />
                    <primitive name="SubIndex" type="UInt8" />
                    <primitive name="DataSize" type="UInt32" />
                    <array name="DataArray" length="DataSize">
                        <primitive name="Data" type="UInt8" />
                    </array>
            </struct>
        </array>
    </struct>
</data>

Actual Results:  
The size of all array elements is determined by the size-member of the first array element.

Expected Results:  
Each array element should have its own size, depending on its size element.
Comment 1 Wolfgang Wallner 2011-08-04 17:24:30 UTC
Created attachment 62546 [details]
Example for a CDC file matching the XML description.

This is one of the CDC files I tried to inspect using Okteta's structure tool.

The example file is taken from the open source powerlink implementation (openPOWERLINK), which means the file is BSD licensed and adding it to bug reports should be ok.
Comment 2 Wolfgang Wallner 2011-08-04 17:26:41 UTC
Created attachment 62547 [details]
Screenshot of the CDC file structure.

The CDC file structure I used to develop my structure XML template.

The picture is a screenshot from the official powerlink specification.
Comment 3 Wolfgang Wallner 2011-08-04 17:29:19 UTC
Created attachment 62548 [details]
*.desktop file I used for my testcase

The *.desktop file I created for my tests. I is based on the information one can find for the Okteta structure tool:

http://docs.kde.org/development/de/kdesdk/okteta/tools-structures.html
http://frinring.wordpress.com/2010/01/16/tutorial-create-your-own-okteta-structure-definitions/
Comment 4 Wolfgang Wallner 2011-08-04 17:31:40 UTC
Created attachment 62549 [details]
*.osd file I used for my testcase

The *.osd file I created for my tests. I is based on the information one
can find for the Okteta structure tool:

http://docs.kde.org/development/de/kdesdk/okteta/tools-structures.html
http://frinring.wordpress.com/2010/01/16/tutorial-create-your-own-okteta-structure-definitions/
Comment 5 Alex Richardson 2011-08-05 15:14:53 UTC
Looking at the code again, it seems it always searches for the first item with matching name starting from the root. It would probably be better to query the direct parent element first. Therefore the length is always the same. I'll try to fix it ASAP
Comment 6 Alex Richardson 2011-08-09 12:04:45 UTC
Created attachment 62694 [details]
A correspongin JavaScript structure definition

This structure definition works as a workaround until I have fixed this bug.
It uses JS to define the structure, which is not documented properly yet.

However I discovered today that parsing of JS structures got broken when adding QT_NO_CAST_FROM_ASCII, so it does not work in 4.7.0. A fix is in SVN, so this will work with the 4.7.1 and 4.8 versions.
Comment 7 Alex Richardson 2011-08-09 12:05:05 UTC
Created attachment 62695 [details]
The desktop file used
Comment 8 Alex Richardson 2011-08-13 20:48:15 UTC
SVN commit 1246953 by arichardson:

Fixed Dynamic arrays always having the length of the first matching element

Now the parent is searched first instead of starting at the highest level

BUG: 279398

 M  +30 -0     datainformation.cpp  
 M  +1 -0      datainformation.h  
 M  +0 -25     datainformationwithchildren.cpp  
 M  +0 -2      datainformationwithchildren.h  
 M  +11 -19    dynamiclengtharraydatainformation.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1246953
Comment 9 Alex Richardson 2011-08-13 20:53:37 UTC
SVN commit 1246955 by arichardson:

Backport r1246953

Fixed Dynamic arrays always having the length of the first matching element

Now the parent is searched first instead of starting at the highest level

BUG: 279398

 M  +30 -0     datainformation.cpp  
 M  +1 -0      datainformation.h  
 M  +0 -25     datainformationwithchildren.cpp  
 M  +0 -2      datainformationwithchildren.h  
 M  +11 -19    dynamiclengtharraydatainformation.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1246955