[trunk] When reducing bar line span, other bar lines are not updated
Setup: rev. 4809; Ubuntu 11.04, Qt SDK 1.1.3 (Qt lib 4.7.4)
Steps:
1) Open or create a score with more than 1 stave; for instance a pianoforte score
2) Select a bar line and enter edit mode
3) Drag the bar line to span fewer staves (1 in the example above)
4) Exit edit mode
Result: neither after 3) or after 4) the other bar lines are update to span fewer staves, only the bar being edited is.
Notes:
1) This happens both for 'original' multiple-stave spans (i.e. created with the instrument, if it uses a grand stave) and for multiple-stave spans created by extending an existing bar line span.
2) When bar line span is increased, all the other bar lines are update to the greater span after step 3) above.
3) When another following action triggers a complete re-laying out (for instance, opening the property dlg of a note, a rest or a measure), 'wrong' bar lines are updated.
Analysis:
The issue is probably due to the fact that, in function BarLine::endEditDrag()
(file barline.cpp, line 515 and seg.), the case when span increases is deal with in lines 515-527, while the case when span decreases seems to be ignored; something like the following code should be added after line 527:
else {
int diff = _span - newSpan;
staffIdx1 += newSpan;
staffIdx2 = staffIdx1 + diff;
Measure* meas = score()->firstMeasure();
while(meas) {
meas->[create bar lines for no-longer-spanned staves];
meas = [next measure];
}
}
Side comments:
1) Should not the whole if (newSpan != _span)
block actually belong to Score::undoChangeBarLineSpan(staff*, int)
?
2) Should not the score()->undoChangeBarLineSpan(staff(), _span)
statement in line 529 actually be in void BarLine::endEdit()
rather than in void BarLine::endDragEdit()
?
Thanks,
M.
Comments
Attached is a patch solving most of the issue.
Changes:
The patch updates (slightly)
libmscore/barline.cpp
andlibmscore/undo.cpp
.In
libmscore/barline.cpp
, propagating the span change from the bar line being edited to all the other bar lines is moved fromBarLine::endDragEdit()
toBarLine::endEdit()
.In
libmscore/undo.cpp
, functionvoid ChangeBarLineSpan::flip()
, the score_layoutAll
flag is set to forceMeasure::createBarLines()
to update all bar lines (otherwise, the staff span parameter is changed, but needed bar lines are not created).These changes makes changes to bar line spans consistently applied to the whole score when exiting edit mode, both while increasing and while decreasing span.
Span changes are also made undoable.
To make easier to review the patch, no existing code has been deleted (only commented out) and some comments have been added.
Not solved:
Span changes are actually undone internally, but they are not drawn on the canvas. This can be seen by:
1) undoing a span change; Result: nothing seems to happen
2) minimizing MuseScore window
3) restoring MuseScore window (which forces a redraw); Result: the span change just undone shows up! No layout update happens here, rather layout changes done in step 1) are finally drawn on the canvas.
I have not been able to correct this part.
Thanks,
M.
patch applied in r4822.
I am currently working on cleaning up command processing. Score layoutFlags updateAll refresh _layoutAll etc. have to be set only in the undo/redo code so that proper layout + screen refresh takes place on undo/redo.
Great, thanks!
You managed to also solve the redraw detail I reported as not solved, but I could not understand how, as my patch seems applied without changes; perhaps you changed something else...
Thanks,
M.
Automatically closed -- issue fixed for 2 weeks with no activity.