Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #25145: Crash relating to StaffTypeChange #26289

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mathesoncalum
Copy link
Contributor

@mathesoncalum mathesoncalum commented Jan 31, 2025

Resolves: #25145

This fix is a two-parter:

  1. 3650d6d - prevent the crash from being reachable in the first place - don't allow StaffTypeChanges to be added to measures that already have StaffTypeChanges (see video for updated behaviour).
  2. b7b4fb7 - handle corrupted StaffTypeChanges in existing scores (show corruption message instead of crashing).
stcdrag.mov

@@ -3475,6 +3481,21 @@ bool Measure::canAddStringTunings(staff_idx_t staffIdx) const
return !alreadyHasStringTunings;
}

bool Measure::canAddStaffTypeChange(staff_idx_t staffIdx) const
{
for (const EngravingObject* child : scanChildren()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Measure::scanChildren does lots of stuff that we don't need here. I think you can more simply use
for (const EngravingItem* item : m_el)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - done!

@mathesoncalum mathesoncalum force-pushed the 25145-stafftype_change_crash branch from d9669e1 to b7b4fb7 Compare January 31, 2025 13:10
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.

Crash or huge memory leak on opening score with Staff Type Change (added twice)
2 participants