Skip to content

Commit

Permalink
Fix musescore#18573: Doubled articulation prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Oct 2, 2023
1 parent 804d948 commit fa24d7b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/engraving/dom/chord.cpp
Expand Up @@ -1861,7 +1861,13 @@ EngravingItem* Chord::drop(EditData& data)
}
atr->setParent(this);
atr->setTrack(track());
score()->undoAddElement(atr);

// Immediately add if the chord has no existing articulations, toggle otherwise...
if (m_articulations.empty()) {
score()->undoAddElement(atr);
} else {
score()->toggleArticulation(this, atr);
}
}
return atr;
}
Expand Down
25 changes: 22 additions & 3 deletions src/engraving/dom/cmd.cpp
Expand Up @@ -2157,9 +2157,28 @@ bool Score::toggleArticulation(EngravingItem* el, Articulation* a)
undoRemoveElement(oa);
return false;
}
a->setParent(c);
a->setTrack(c->track()); // make sure it propagates between score and parts
undoAddElement(a);

if (!a->isDouble()) {
a->setParent(c);
a->setTrack(c->track());
undoAddElement(a);
return true;
}

// Split the new articulation into "sub-components", only add the unique ones (not present in the chord)...
std::set<SymId> newSubComponentIds = splitArticulations({ a->symId() });
for (const SymId& id : newSubComponentIds) {
Articulation* articCopy = a->clone();
articCopy->setSymId(id);

if (!c->hasArticulation(articCopy)) {
articCopy->setParent(c);
articCopy->setTrack(c->track());
undoAddElement(articCopy);
continue;
}
delete articCopy;
}
return true;
}

Expand Down

0 comments on commit fa24d7b

Please sign in to comment.