[trunk] Nudget time sig gets more and more displaced at each save and re-load

• Sep 13, 2011 - 11:29
S4 - Minor

Setup: rev. 4776; Ubuntu 11.04, Qt SDK 1.1.3 (Qt lib 4.7.4)


1) Create a score whatsoever
2) Displace horizontally the initial time signature by some value (for instance, use the Inspector to set an Offset X = 2.00sp; note that the Inspector already shows some positive horiz. displacement: 0.30sp with default style)
3) Save the score and close it
4) Re-load the score

Result: the time signature is now displaced by 2.30sp (= user offset + original displacement)

Each time the score is saved and re-loaded the horiz. displacement grows by another 0.3sp

A sample score is attached with just 1 measure and time signature with Offset X = 2.00sp (initially) in 4 iterations of the save-reload process: the actual displacements of the time signature, as hown by the Inspector, are:
2.3 | 2.6 | 2.9 | 3.2

There seems to be some confusion about which part of the element total position offset is due to internal laying out processes and which to user intervention (I assume this is what the Element::_pos and Element::_userOff member vars are for).

the Inspector 1a) initially shows 0.0 offsets and 1b) stores the whole user-inserted values into _userOff
it 2a) initially shows the 'built-in' offset (_pos) and 2b) stores in _userOff the difference between the 'built-in' offset and the user-inserted values

BUT the Inspector SHOULD NOT do 2a) and 1b), as it does now.
- - - - - - - -
Alternatively, the function QList Element::properties(Xml& xml, const Element* proto) in file libmscore/element.cpp, line 583
    pl.append(Prop("pos", pos() / spatium()));
should not save the whole displacements (pos() <= _pos + _userOff), but only _userOff.




fixed in r4778.
The position of an element (pos) saved in the xml file is the sum of layout position (element->_pos) + user offset
(element->userOffset). This gives the position relative to the element anchor.
On read this value is put aside in "readPos" and used after layout of the element to reconstruct the user offset.

The bug was caused by reconstructing the values before the actual positioning of the element took place.