Skip to content

Commit

Permalink
fix #307433: fixed crash when adding voltas in continuous view and im…
Browse files Browse the repository at this point in the history
…proved behaviour with repeats
  • Loading branch information
SKefalidis committed Jul 7, 2020
1 parent 3a1fcf9 commit 21e178c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions libmscore/repeatlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ void RepeatList::preProcessVoltas()
}
}
// found the real ending of this volta, store it to minimize search efforts
Q_ASSERT(voltaEndMeasure != nullptr);
_voltaRanges.insert(std::pair<Volta*, Measure*>(volta, voltaEndMeasure));
nextVolta = volta; // this volta might indicate the end of the previous one
}
Expand Down
14 changes: 14 additions & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4217,6 +4217,20 @@ int Score::duration()
return lrint(utick2utime(rs->utick + rs->len()));
}

//---------------------------------------------------------
// durationWithoutRepeats
//---------------------------------------------------------

int Score::durationWithoutRepeats()
{
masterScore()->setExpandRepeats(false);
const RepeatList& rl = repeatList();
if (rl.empty())
return 0;
const RepeatSegment* rs = rl.last();
return lrint(utick2utime(rs->utick + rs->len()));
}

//---------------------------------------------------------
// createRehearsalMarkText
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ class Score : public QObject, public ScoreElement {
QString extractLyrics();
int keysig();
int duration();
int durationWithoutRepeats();

void cmdInsertClef(Clef* clef, ChordRest* cr);

Expand Down
4 changes: 2 additions & 2 deletions mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void ScoreView::moveControlCursor(const Fraction& tick)
else { // reposition the cursor when the score is not playing
double curOffset = _cursor->rect().x() - score()->firstMeasure()->pos().x();
double length = score()->lastMeasure()->pos().x() - score()->firstMeasure()->pos().x();
_timeElapsed = (curOffset / length) * score()->duration() * 1000;
_timeElapsed = (curOffset / length) * score()->durationWithoutRepeats() * 1000;
_controlModifier = _panSettings.controlModifierBase;
}

Expand All @@ -733,7 +733,7 @@ void ScoreView::moveControlCursor(const Fraction& tick)


// Calculate the position of the controlCursor based on the timeElapsed (which is not the real time that has passed)
qreal x = score()->firstMeasure()->pos().x() + (score()->lastMeasure()->pos().x() - score()->firstMeasure()->pos().x()) * (_timeElapsed / (score()->duration() * 1000));
qreal x = score()->firstMeasure()->pos().x() + (score()->lastMeasure()->pos().x() - score()->firstMeasure()->pos().x()) * (_timeElapsed / (score()->durationWithoutRepeats() * 1000));
x -= score()->spatium();
_controlCursor->setRect(QRectF(x, _cursor->rect().y(), _cursor->rect().width(), _cursor->rect().height()));
update(_matrix.mapRect(_controlCursor->rect()).toRect().adjusted(-1,-1,1,1));
Expand Down

0 comments on commit 21e178c

Please sign in to comment.