Skip to content

Commit

Permalink
Fix #321716: Fix entering 8th notes in REALTIME MIDI input modes
Browse files Browse the repository at this point in the history
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
  • Loading branch information
fxthomas authored and Jojo-Schmitz committed Nov 23, 2021
1 parent e00dbe6 commit a65ad7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libmscore/noteentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Note* Score::addPitch(NoteVal& nval, bool addFlag, InputState* externalInputStat
// We could split the duration at the barline and continue into the next bar, but this would create extra
// notes, extra ties, and extra pain. Instead, we simply truncate the duration at the barline.
Fraction ticks2measureEnd = is.segment()->measure()->ticks() - is.segment()->rtick();
duration = is.duration() > ticks2measureEnd ? ticks2measureEnd : is.duration().fraction();
duration = is.duration().fraction() > ticks2measureEnd ? ticks2measureEnd : is.duration().fraction();
}
else {
duration = is.duration().fraction();
Expand Down

0 comments on commit a65ad7b

Please sign in to comment.