Skip to content

Commit

Permalink
Fix #332925: Half duration shortcut crashes when time signature is 5/4
Browse files Browse the repository at this point in the history
Crash happens only in Debug builds.

Backport of musescore#12084, improved version, the crash was fixed already in the earlier version.
  • Loading branch information
Jojo-Schmitz committed May 23, 2023
1 parent 9b44571 commit 074da27
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2702,8 +2702,19 @@ void Score::cmdIncDecDuration(int nSteps, bool stepDotted)

// if measure rest is selected as input, then the correct initialDuration will be the
// duration of the measure's time signature, else is just the input state's duration
TDuration initialDuration = (cr->durationType() == TDuration::DurationType::V_MEASURE) ? TDuration(cr->measure()->timesig(), true) : _is.duration();
TDuration d = initialDuration.shiftRetainDots(nSteps, stepDotted);
TDuration initialDuration;
if (cr->durationType() == TDuration::DurationType::V_MEASURE) {
initialDuration = TDuration(cr->measure()->timesig(), true);

if (initialDuration.fraction() < cr->measure()->timesig() && nSteps > 0) {
// Duration already shortened by truncation; shorten one step less
--nSteps;
}
}
else {
initialDuration = _is.duration();
}
TDuration d = (nSteps != 0) ? initialDuration.shiftRetainDots(nSteps, stepDotted) : initialDuration;
if (!d.isValid())
return;
if (cr->isChord() && (toChord(cr)->noteType() != NoteType::NORMAL)) {
Expand Down

0 comments on commit 074da27

Please sign in to comment.