Skip to content

Commit

Permalink
Remove linked elements on mmRests when moving segments
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Mar 10, 2025
1 parent 10cb7a9 commit d260b22
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/engraving/dom/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3435,6 +3435,24 @@ bool TextBase::moveSegment(const EditData& ed)

void TextBase::undoMoveSegment(Segment* newSeg, Fraction tickDiff)
{
// NOTE: when creating mmRests, we clone text elements from the underlying measure onto the
// mmRest measure. This creates lots of additional linked copies which are hard to manage
// and can result in duplicates. Here we need to remove copies on mmRests because they are invalidated
// when moving segments (and if needed will be recreated at the next layout). In future we need to
// change approach and *move* elements onto the mmRests, not clone them. [M.S.]
std::list<EngravingObject*> linkedElements = linkList();
for (EngravingObject* linkedElement : linkedElements) {
if (linkedElement == this) {
continue;
}
Segment* curParent = toSegment(linkedElement->parent());
bool isOnMMRest = curParent->parent() && toMeasure(curParent->parent())->isMMRest();
if (isOnMMRest) {
linkedElement->undoUnlink();
score()->undoRemoveElement(static_cast<EngravingItem*>(linkedElement));
}
}

score()->undoChangeParent(this, newSeg, staffIdx());
moveSnappedItems(newSeg, tickDiff);
}
Expand Down

0 comments on commit d260b22

Please sign in to comment.