Skip to content
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

Merged
merged 2 commits into from Aug 13, 2021
Merged

Paste note fixes #8825

merged 2 commits into from Aug 13, 2021

Conversation

wizofaus
Copy link
Contributor

@wizofaus wizofaus commented Aug 10, 2021

Resolves: #8824

Ensure that pasting notes works as expected in all circumstances

  • I signed CLA
  • I made sure the code in the PR follows the coding rules
  • I made sure the code compiles on my machine
  • I made sure there are no unnecessary changes in the code
  • I made sure the title of the PR reflects the core meaning of the issue you are solving
  • I made sure the commit message(s) contain a description and answer the question "Why do those changes fix that particular issue?" or "Why are those changes really necessary as improvements?"
  • I made sure the commit message title starts with "fix #424242:" if there is a related issue
  • I created the test (mtest, vtest, script test) to verify the changes I made

…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;
Copy link
Contributor Author

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)) {
Copy link
Contributor Author

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

} else if (target->isChordRest()) {
newEl = replaceNote(toChordRest(target), toNote(newEl), duration);
} else {
target->drop(ddata);
Copy link
Contributor Author

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...

@Jojo-Schmitz
Copy link
Contributor

There's a merge commit that doesn't belong into this PR.
Is this supposed to fix https://musescore.org/en/node/321809 for master? Alternative to the 2nd commit for #8818?

@wizofaus
Copy link
Contributor Author

There's a merge commit that doesn't belong into this PR.
Is this supposed to fix https://musescore.org/en/node/321809 for master? Alternative to the 2nd commit for #8818?

That came from a rebase. I tried to squash but it wouldn't play nicely. Need to fix the code-style thing though.

@wizofaus
Copy link
Contributor Author

And when I say "fix", I mean screw up my sensible formatting to suit the current version of uncrustify used by the git workflows.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Aug 10, 2021

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?

@wizofaus
Copy link
Contributor Author

It preserves the length of the note you copied, which is consistent with how it works when pasted onto anything else.
That's a new behaviour of MU4 (MU3 only ever transferred the pitch as the clipboard data didn't even include the note duration).

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Aug 10, 2021

But that then is not what you describe as the desired outcome in section a) of #8824

@wizofaus
Copy link
Contributor Author

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).

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Aug 10, 2021

Pasting a note on to a multi-measure rest should behave the same as pasting onto a whole rest,
That's not what it does
Hmm, OK, not what it did in 3.x...

@wizofaus
Copy link
Contributor Author

BTW this is not ready for merge yet, still a number of issues I just discovered.

@RobFog
Copy link

RobFog commented Aug 10, 2021

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.

@wizofaus wizofaus marked this pull request as draft August 10, 2021 23:10
@wizofaus
Copy link
Contributor Author

I'd looked for that option (convert to draft), couldn't see it, it's not very obvious!

chord->setTicks(ticks());
chord->setTuplet(tuplet());
chord->add(note);
score()->undoAddCR(chord, seg->measure(), seg->tick());
Copy link
Contributor Author

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);
Copy link
Contributor Author

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

@wizofaus wizofaus force-pushed the paste_note_fixes branch 2 times, most recently from 3de4786 to 3d1f2e1 Compare August 11, 2021 10:54
@@ -0,0 +1,4438 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
Copy link
Contributor

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

Copy link
Contributor Author

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!

Copy link
Contributor

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.

@wizofaus wizofaus marked this pull request as ready for review August 11, 2021 12:06
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 11, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 11, 2021
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.
return target;
}

static bool canPasteStaff(XmlReader& reader, const Fraction& scale)
Copy link
Contributor Author

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);
Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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!).

Copy link
Contributor Author

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.

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 12, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 12, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 12, 2021
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.
@RomanPudashkin RomanPudashkin merged commit 494582a into musescore:master Aug 13, 2021
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 13, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 13, 2021
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.
@Jojo-Schmitz Jojo-Schmitz mentioned this pull request Aug 13, 2021
8 tasks
@vshalkevich
Copy link

Works fine

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 19, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 19, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 30, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 1, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 2, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 9, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 10, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 23, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 26, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 29, 2021
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request May 12, 2022
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.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 5, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MU4 Issue] Pasting notes onto rests not reliable
6 participants