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

Fix #306917: Crash on tie in score with parts #6242

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4532,17 +4532,48 @@ void Score::undoAddElement(Element* element)
return;
}

// For linked staves the length of staffList is always > 1 since the list contains the staff itself too!
const bool linked = ostaff->staffList().length() > 1;

for (Staff* staff : ostaff->staffList()) {
Score* score = staff->score();
int staffIdx = staff->idx();

QList<int> tr;
if ((strack & ~3) != staffIdx) // linked staff ?
tr.append(staffIdx * VOICES + (strack % VOICES));
else if (staff->score()->excerpt() && strack > -1)
tr = staff->score()->excerpt()->tracks().values(strack);
else
tr.append(strack);
if (!staff->score()->excerpt()) {
// On masterScore.
int track = staff->idx() * VOICES + (strack % VOICES);
tr.append(track);
}
else {
QMultiMap<int, int> mapping = staff->score()->excerpt()->tracks();
if (mapping.isEmpty()) {
// This can happen during reading the score and there is
// no Tracklist tag specified.
// TODO solve this in read301.cpp.
tr.append(strack);
}
else {
for (int track : mapping.values(strack)) {
// linkedPart : linked staves within same part/instrument.
// linkedScore: linked staves over different scores via excerpts.
const bool linkedPart = linked && (staff != ostaff) && (staff->score() == ostaff->score());
const bool linkedScore = linked && (staff != ostaff) && (staff->score() != ostaff->score());
if (linkedPart && !linkedScore) {
tr.append(staff->idx() * VOICES + mapping.value(track));
}
else if (!linkedPart && linkedScore) {
if ((track >> 2) != staffIdx)
track += (staffIdx - (track >> 2)) * VOICES;
tr.append(track);
}
else {
tr.append(track);
}
}
}
}


// Some elements in voice 1 of a staff should be copied to every track which has a linked voice in this staff

Expand All @@ -4565,13 +4596,7 @@ void Score::undoAddElement(Element* element)
tr.append(staffIdx * VOICES);
}

int it = 0;
for (int ntrack : tr) {
if ((ntrack & ~3) != staffIdx * VOICES) {
it++;
continue;
}

Element* ne;
if (staff == ostaff)
ne = element;
Expand Down Expand Up @@ -4880,7 +4905,6 @@ void Score::undoAddElement(Element* element)
}
else
qWarning("undoAddElement: unhandled: <%s>", element->name());
it++;
}
}
}
Expand Down