From 42f32f8088e7ae2315e3eec6173e3d5bf48c6b29 Mon Sep 17 00:00:00 2001 From: sammik Date: Sun, 11 Aug 2024 06:40:01 +0200 Subject: [PATCH] when deleting "global key signature" in part, make sure all key signatures in score will be deleted too --- src/engraving/dom/edit.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/engraving/dom/edit.cpp b/src/engraving/dom/edit.cpp index 17e83a0d8ce86..2672cfa83d62a 100644 --- a/src/engraving/dom/edit.cpp +++ b/src/engraving/dom/edit.cpp @@ -3567,6 +3567,24 @@ void Score::cmdDeleteSelection() for (EngravingObject* se : links) { deletedElements.insert(se); } + + // when deleting "global key signature" in part, + // make sure all key signatures in score will be deleted too + // (part score doesn't need to contain all staves) + if (e->isKeySig() && !score()->isMaster() && toSegment(e->explicitParent())->empty()) { + for (EngravingObject* linkedSig : links) { + Score* score = linkedSig->score(); + if (score->isMaster()) { + Segment* keySeg = toSegment(linkedSig->explicitParent()); + for (staff_idx_t i = 0; i < score->nstaves(); ++i) { + track_idx_t track = i * VOICES; + if (EngravingItem* sig = keySeg->element(track)) { + score->deleteItem(sig); + } + } + } + } + } } }