From 36a447a0c0c3c7a0c1277e4e7e1202e4b0c7e548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Thomas?= Date: Thu, 21 Oct 2021 16:54:16 +0200 Subject: [PATCH] Fix #321716: Fix entering 8th notes in REALTIME MIDI input modes 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. --- libmscore/noteentry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmscore/noteentry.cpp b/libmscore/noteentry.cpp index 12bd3699a7b3e..df983159bd0b8 100644 --- a/libmscore/noteentry.cpp +++ b/libmscore/noteentry.cpp @@ -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();