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 #283964 - Linked parts for single voices don't work #6049

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
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
45 changes: 36 additions & 9 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4889,17 +4889,44 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, const Fraction& tick)

Tuplet* t = cr->tuplet();

// 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 (const Staff* staff : ostaff->staffList()) {
QList<int> tracks;
int staffIdx = staff->idx();
if ((strack & ~3) != staffIdx) // linked staff ?
tracks.append(staffIdx * VOICES + (strack % VOICES));
else if (staff->score()->excerpt() && !staff->score()->excerpt()->tracks().isEmpty())
tracks = staff->score()->excerpt()->tracks().values(strack);
else if (!staff->score()->excerpt())
tracks.append(staffIdx * VOICES + (strack % VOICES));
else
tracks.append(staffIdx * VOICES + cr->voice());
if (!staff->score()->excerpt()) {
// On masterScore.
int track = staff->idx() * VOICES + (strack % VOICES);
tracks.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.
tracks.append(strack);
}
else {
// 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());
for (int track : mapping.values(strack)) {
if (linkedPart && !linkedScore) {
tracks.append(staff->idx() * VOICES + mapping.value(track));
}
else if (!linkedPart && linkedScore) {
if ((track >> 2) != staff->idx())
track += (staff->idx() - (track >> 2)) * VOICES;
tracks.append(track);
}
else {
tracks.append(track);
}
}
}
}

for (int ntrack : tracks) {
if (ntrack < staff->part()->startTrack() || ntrack >= staff->part()->endTrack())
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ void MasterScore::addExcerpt(Excerpt* ex)
}
}
}
if (ex->tracks().isEmpty()) { // SHOULDN'T HAPPEN, protected in the UI
if (ex->tracks().isEmpty()) { // SHOULDN'T HAPPEN, protected in the UI, but it happens during read-in!!!
QMultiMap<int, int> tracks;
for (Staff* s : score->staves()) {
const LinkedElements* ls = s->links();
Expand Down