Skip to content

Commit

Permalink
Merge pull request #4960 from mattmcclinch/288227-paste-linked-tie
Browse files Browse the repository at this point in the history
fix #288227: Copy-paste tied notes included in linked staves in a score with parts leads to crash
  • Loading branch information
dmitrio95 committed Apr 27, 2019
2 parents d7778ca + 18e4f45 commit c8e8042
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions libmscore/edit.cpp
Expand Up @@ -3755,8 +3755,15 @@ static Element* findLinkedVoiceElement(Element* e, Staff* nstaff)

if (de) {
QList<int> l = de->tracks().values(strack);
if (l.isEmpty())
if (l.isEmpty()) {
// simply return the first linked element whose staff is equal to nstaff
for (ScoreElement* ee : e->linkList()) {
Element* el = toElement(ee);
if (el->staff() == nstaff)
return el;
}
return 0;
}
for (int i : l) {
if (nstaff->idx() * VOICES <= i && (nstaff->idx() + 1) * VOICES > i) {
dtrack = i;
Expand Down Expand Up @@ -3789,8 +3796,15 @@ static Chord* findLinkedChord(Chord* c, Staff* nstaff)

if (de) {
QList<int> l = de->tracks().values(strack);
if (l.isEmpty())
if (l.isEmpty()) {
// simply return the first linked chord whose staff is equal to nstaff
for (ScoreElement* ee : c->linkList()) {
Chord* ch = toChord(ee);
if (ch->staff() == nstaff)
return ch;
}
return 0;
}
for (int i : l) {
if (nstaff->idx() * VOICES <= i && (nstaff->idx() + 1) * VOICES > i) {
dtrack = i;
Expand Down
2 changes: 1 addition & 1 deletion libmscore/read206.cpp
Expand Up @@ -3773,9 +3773,9 @@ static bool readScore(Score* score, XmlReader& e)
Excerpt* ex = new Excerpt(m);

ex->setPartScore(s);
ex->setTracks(e.tracks());
e.setLastMeasure(nullptr);
readScore(s, e);
ex->setTracks(e.tracks());
m->addExcerpt(ex);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libmscore/read301.cpp
Expand Up @@ -170,9 +170,9 @@ bool Score::read(XmlReader& e)
Excerpt* ex = new Excerpt(m);

ex->setPartScore(s);
ex->setTracks(e.tracks());
e.setLastMeasure(nullptr);
s->read(e);
ex->setTracks(e.tracks());
m->addExcerpt(ex);
}
}
Expand Down

0 comments on commit c8e8042

Please sign in to comment.