Skip to content

Conversation

@manolo
Copy link
Contributor

@manolo manolo commented Jan 5, 2026

Resolves: #31656

When renaming a part in the Parts dialog, the new name wasn't persisted to the .mscz file unless the part had been opened as a tab first.

Root cause: "Potential" excerpts shown in the Parts dialog are not in masterScore()->excerpts() until explicitly created. Since mscsaver only saves excerpts in the master's list, renaming a potential excerpt had no effect.

Solution: ChangeExcerptTitle now checks if the excerpt is in the master's list before renaming. If not, it calls initAndAddExcerpt() to add it, ensuring it gets saved.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

manolo added 4 commits January 5, 2026 10:16
Test that renaming a 'potential' excerpt (not yet in master's
excerpts list) persists after save/reload.

This test fails without the corresponding fix because:
- Potential excerpts are not in master->excerpts()
- mscsaver only saves excerpts in the master's list
- So the renamed excerpt is not saved to disk
When renaming a 'potential' excerpt (shown in Parts dialog but not
yet created), ChangeExcerptTitle now auto-adds it to master's
excerpts list if not present.

This ensures the excerpt gets saved to disk, fixing the bug where
part names changed in the Parts dialog weren't saved if the part
hadn't been opened as a tab.

Fixes musescore#31656
The previous fix added the auto-add logic to ChangeExcerptTitle, but
undoSetName() was returning early when score() is null (which happens
for potential excerpts), never reaching ChangeExcerptTitle.

Use m_excerpt->masterScore() instead of score() to get the master,
allowing the rename to proceed and trigger ChangeExcerptTitle.
@bkunda bkunda requested a review from cbjeukendrup January 9, 2026 15:50
@bkunda bkunda added the needs review The issue needs review to set priority, fix version or change status etc. label Jan 9, 2026
@cbjeukendrup cbjeukendrup removed the needs review The issue needs review to set priority, fix version or change status etc. label Jan 9, 2026
Copy link
Member

@cbjeukendrup cbjeukendrup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not ideal, because initialising an excerpt is an expensive operation, and it is wasteful to populate and store the entire excerptScore while we only really need to store the excerpt's name.

Instead, the solution to this and some other issues, should be to move the concept of "potential excerpts" to the engraving/dom level, instead of having it at the MasterNotation/PartListModel level.
Potential excerpts should just be Excerpt but with no Score yet. Such excerpts should be created for each instrument when the master score is initially created, and when new instruments are added.
They should be stored in the MSCZ file, even if no properties have been modified compared to the defaults. However, the file format for potential excerpts might need to be slightly different because of the absence of a Score. It should only store a name and a list of Parts.

This is a somewhat big refactor, but I think it's worth it. It would also result in the ability to delete potential excerpts without having them appear back next time you open the parts dialog, and it would make it easier to fix the problems with the reset functionality.

Let us know if you're happy to look into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Part name changes in Parts dialog not saved until part is opened as tab

3 participants