Skip to content

Fix: Update clef elements when changing default instrument#32630

Merged
RomanPudashkin merged 1 commit intomusescore:masterfrom
CubikingChill:fix/instrument-change-clef-regression
Mar 20, 2026
Merged

Fix: Update clef elements when changing default instrument#32630
RomanPudashkin merged 1 commit intomusescore:masterfrom
CubikingChill:fix/instrument-change-clef-regression

Conversation

@CubikingChill
Copy link
Contributor

@CubikingChill CubikingChill commented Mar 15, 2026

This fixes a regression introduced by 99b5b5b ("EditStaff: don't unexpectedly change clef when pressing OK without making changes").

That commit changed applyStaffProperties() to read the clef from m_staff->defaultClefType() instead of m_instrument.clefType(). However, showReplaceInstrumentDialog() never updates m_staff's default clef type when the instrument changes, so on the second apply() call (Apply then OK), applyStaffProperties() sends the stale old clef, reverting the change.

The fix adds m_staff->setDefaultClefType(m_instrument.clefType(0)) in showReplaceInstrumentDialog() to keep m_staff consistent with the selected instrument.

Resolves: #32633

  • 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)

@CubikingChill CubikingChill force-pushed the fix/instrument-change-clef-regression branch from 9a11ebd to 392a1c0 Compare March 15, 2026 21:38
@mercuree

This comment was marked as outdated.

@CubikingChill
Copy link
Contributor Author

Am I correct in understanding that this PR directly depends on #32499, which has not been merged yet?

Yes. But is sticking to the old way of setting part default clef better?

@CubikingChill CubikingChill force-pushed the fix/instrument-change-clef-regression branch 6 times, most recently from 409e413 to db22639 Compare March 16, 2026 16:14
@CubikingChill CubikingChill force-pushed the fix/instrument-change-clef-regression branch from db22639 to 68491cf Compare March 16, 2026 16:31
@CubikingChill CubikingChill reopened this Mar 16, 2026
@CubikingChill CubikingChill force-pushed the fix/instrument-change-clef-regression branch 10 times, most recently from b355f90 to d43895f Compare March 17, 2026 10:34
@CubikingChill
Copy link
Contributor Author

Changed to a more minimal fix. Ready for review.

@avvvvve avvvvve requested a review from mike-spa March 17, 2026 15:13
@RomanPudashkin RomanPudashkin requested review from mathesoncalum and removed request for mike-spa March 19, 2026 07:54
Co-authored-by: Cubiking <yuk.chiu@student.manchester.ac.uk>
@mathesoncalum mathesoncalum force-pushed the fix/instrument-change-clef-regression branch from d43895f to d4fea40 Compare March 19, 2026 12:44
Copy link
Contributor

@mathesoncalum mathesoncalum left a comment

Choose a reason for hiding this comment

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

Looks good @CubikingChill. FYI I've re-committed with a more descriptive commit message (the original was just "fix"). If you could keep this in mind for any future PRs that would great - thank you!

@CubikingChill
Copy link
Contributor Author

Noted. Thank you.

@RomanPudashkin RomanPudashkin merged commit d3a4163 into musescore:master Mar 20, 2026
12 checks passed
@CubikingChill
Copy link
Contributor Author

Can you check the latest nightly? I don't think the fix works :(

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.

Default clef doesn't update when changing part's default instrument

4 participants