musescore / musescore/MuseScore

Deleting a range leaves empty rhythmic segments in linked parts

Open
#34,859 0 comments 0 reactions 1 assignee View on GitHub

@miiizen is already working on this.

Since Sep 11, 2026.

needs review P2
Dominant language
C++
Stars
15.1k
Forks
3.3k
Avg merge
2d 2h
Merged PRs (30d)
91

Description

Issue type

Other type of issue

Description with steps to reproduce
  1. Open the attached score, whose first measure contains four quarter rests.
  2. Create/open its part.
  3. Select the first measure in the full score and delete its contents. The same problem occurs when deleting from the part.

Both scores correctly contain a full-measure rest afterward, but the linked score retains three empty ChordRest segments at the former rest positions. The score receiving the command has one rhythmic segment; its linked score still has four. The empty segments should be removed from both scores. Undo should restore the original four rests and redo should remove the empty segments again.

This is a native score-structure regression; I have not established a visible engraving or playback difference.

Supporting files, videos and screenshots

Minimal score

Native reproduction: Engraving_PartsTests.deleteLinkedRestsRemovesEmptySegments. On unpatched main, the linked score has four rhythmic segments where the test expects one, including three for which Segment::empty() is true. The same test passes with the candidate correction, including both command-entry scores, undo, redo and saving/reopening.

A before/after desktop video would look the same for this example, so the native assertions provide the relevant evidence.

In which versions of MuseScore Studio is this issue present?

Development 5.0.0, official main 8d6bbe95efef28ccf2c05d6773cebcd364e505b6, native C++ Debug build.

Regression

I was unable to check older releases.

Operating system

Linux (Ubuntu 24.04, x86_64)

Additional context

Score::removeChordRest loops over linked chord/rest objects, but collects cr->segment() each time instead of the current linked object's segment. The existing emptiness check and undo removal then only visit the initiating score's segment.

Related PR #30175 concerns empty-segment cleanup during Excerpt::cloneStaff2, rather than deletion of existing linked content.

AI was used to improve efficiency during development.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.