New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paste note fixes #8825
Paste note fixes #8825
Conversation
…el_restoring_state [MU4] Various fixes for the instruments panel
@@ -1433,7 +1433,7 @@ void ChordRest::removeMarkings(bool /* keepTremolo */) | |||
bool ChordRest::isBefore(const ChordRest* o) const | |||
{ | |||
if (!o || this == o) { | |||
return true; | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent asserts due to unstable std::sort predicates.
@@ -453,7 +453,7 @@ Rest* Score::setRest(const Fraction& _tick, int track, const Fraction& _l, bool | |||
// compute list of durations which will fit l | |||
// | |||
std::vector<TDuration> dList; | |||
if (tuplet || staff->isLocalTimeSignature(tick)) { | |||
if (tuplet || staff->isLocalTimeSignature(tick) || f == Fraction(0, 1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was crashing without this when pasting, e.g. a whole note onto a multi-measure rest, the 'else' part of this test definitely doesn't work if f
is 0 anyway
src/engraving/libmscore/paste.cpp
Outdated
} else if (target->isChordRest()) { | ||
newEl = replaceNote(toChordRest(target), toNote(newEl), duration); | ||
} else { | ||
target->drop(ddata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would prefer that above logic was all inside Note::drop( ) and ChordRest::drop( ) but would require adding even more info (duration) to the already-bloated EditData structure...
There's a merge commit that doesn't belong into this PR. |
That came from a rebase. I tried to squash but it wouldn't play nicely. Need to fix the code-style thing though. |
And when I say "fix", I mean screw up my sensible formatting to suit the current version of uncrustify used by the git workflows. |
ed27d23
to
0fd10fe
Compare
As far as I can tell this PR, on dropping a notehead of a quarter note onto an MMRest, pastes a quarter note, not a note equal to a the full lenghth of the measure? |
It preserves the length of the note you copied, which is consistent with how it works when pasted onto anything else. |
But that then is not what you describe as the desired outcome in section a) of #8824 |
Yes it is, because pasting on to a whole measure rest in MU4 does preserve the length of the copied note (adding/removing rests as required to fit it on). |
Pasting a note on to a multi-measure rest should behave the same as pasting onto a whole rest, |
BTW this is not ready for merge yet, still a number of issues I just discovered. |
You can mark the pull request as a draft. |
I'd looked for that option (convert to draft), couldn't see it, it's not very obvious! |
0fd10fe
to
a88a567
Compare
chord->setTicks(ticks()); | ||
chord->setTuplet(tuplet()); | ||
chord->add(note); | ||
score()->undoAddCR(chord, seg->measure(), seg->tick()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing method failed to transfer all properties and didn't work with tuplets etc.
// the returned gap ends at the measure boundary or at tuplet end | ||
Fraction dd = makeGap(segment, track, sd, cr ? cr->tuplet() : 0); | ||
Fraction dd = makeGap(segment, track, sd, tuplet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the changes here are about ensuring that a) if the element at the segment position is a rest, then any other notes that would be overlapped get removed instead of being "split" into component durations - actually I'd rather simplify this so that setNoteRest always does that but it may have unexpected side effects and b) only the initial tuplet is preserved where possible - the existing logic tried to preserve all tuplets that fell inside the duration, which didn't make sense for any case I could think of
3de4786
to
3d1f2e1
Compare
@@ -0,0 +1,4438 @@ | |||
/* | |||
* SPDX-License-Identifier: GPL-3.0-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this file doesn't belong into the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd removed it within minutes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But not pushed it equally fast I guess? Anyway, issue is sorted now.
3d1f2e1
to
f011e9a
Compare
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
86c5dae
to
e637400
Compare
return target; | ||
} | ||
|
||
static bool canPasteStaff(XmlReader& reader, const Fraction& scale) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to prevent crashing when using "paste half length" on a range with 1/1024th notes, a bit kludgy but I tried a few other ways and this was the more reliable and least code by far
if (!pasteStaff(e, cr->segment(), cr->staffIdx(), scale)) { | ||
return; | ||
if (canPasteStaff(e, scale)) { | ||
XmlReader e(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XmlReader doesn't have a rewind...should add one perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already declared XmlReader e(data) at line 1166. We will get a warning here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declared? Rather called. So it might get called twice now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, you can't rewind it so you have to create a new one... happy to add a rewind function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you used the same name twice in two different declarations. You can move this code in a separate method or just rename the second reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're in different scopes so the behavior is well defined, but I agree stylistically some may prefer avoiding reusing the name (actually I don't like single letter variable names generally!).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took your suggestion of creating a separate method, creating a rewind method was a bit painful/dangerous due to inner workings of Qt.
e637400
to
7245915
Compare
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
7245915
to
dc91cae
Compare
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Works fine |
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Backport of musescore#8825, better fix than musescore#8816, better even than my alternative, which this commits reverts. It does however change the way noteheads are pasted: now with the duration of the source chord rather than the duration of the target.
Resolves: #8824
Ensure that pasting notes works as expected in all circumstances