Paste / "R" repositions continuous view to point of last note entry

• Sep 16, 2014 - 01:41
Type
Functional
Severity
S4 - Minor
Status
closed
Project

Ubuntu Studio 14.04, GIT commit: 3338af9

1) new score, 100 measures
2) switch to Continuous View
3) enter some notes into measure 1
4) Hit "End" to move to end of score
5) enter some notes into measure 100
6) Hit "Home" to move back to beginning of score
7) select measure 1
8) press "R" to copy it to measure 2

Result: view jumps to the end of score. Same result if you copy and paste. On paste, score always jumps to position of last note entry.

At first this seemed random to me, but after some testing, I have concluded it's remembering the last input position and trying to position to that.


Comments

Problem seems to occur here:

https://github.com/musescore/MuseScore/blob/master/mscore/scoreview.cpp…

During the paste operation, we call adjustCanvasPositition, passing in the first element in the pasted region. So we *should* be positioning the canvas to display that element. However, nowhere in adjustCanvasPosition does it appear to actually *use* the passed in element - at least, not while in continuous view. Instead, it uses "_cursor", which is still loaded with the last input position. Hence the bug.

I don't understand the code well enough to say why we might be ignoring the passed in element and using the cursor position instead, but perhaps that could be done only if in note entry mode? I can verify that if we use el->canvasBoundingRect() instead of _cursor->rect(), pasting at least works well. So does note entry as far as I can tell, but I know this code was recently changed to fix a number of bugs, so I figure there is some reason behind how things are done.

I browsed the history and found that until a few months ago, adjustCanvasPosition() *was* using el rather than _cursor even in Continuous view. The change was made as part of the fix for #15212: Score does not pan properly during playback when in Continuous View and zoom. When I change the code back to using el rather than _cursor, I find that #15212 remains fixed - it seems it wasn't the change from el to _cursor that fixed the problem, but rather, the other changes made at the same time (see https://github.com/musescore/MuseScore/commit/4a389ed81fc80c0f19abb78cc…). But again, I recognize that this code is probably delicate, so I'm still reluctant to submit a PR that simply changes it back without input from someone who knows more about this.

FWIW, the original code used el->x()->canvasPos().x() and that plus el->width() for the left and right edges to adjust to, whereas I was suggesting el->canvasBoundingRect().left() and el->canvasBoundingRect().right(). Should be more or less the same thing, but maybe that difference is also significant here for some reason.