-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix potential excerpt rename not persisting (implements lightweight excerpts) #31738
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
Open
manolo
wants to merge
10
commits into
musescore:master
Choose a base branch
from
manolo:fix/potential-excerpt-rename-persistence
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix potential excerpt rename not persisting (implements lightweight excerpts) #31738
manolo
wants to merge
10
commits into
musescore:master
from
manolo:fix/potential-excerpt-rename-persistence
+653
−24
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 tasks
707e3d9 to
26c498e
Compare
Contributor
Author
|
@cbjeukendrup let me know if the implementation fits your suggestions. If so, I can continue with the two issues you mentioned regarding reset and delete functionality, probably in a separate PR once this is accepted. |
…1656) Add tests to verify that excerpt properties can be stored and persisted: - uninitializedExcerptProperties: verifies that an Excerpt without excerptScore can store name and parts - renamePotentialExcerpt: verifies that excerpt names persist through save/reload (baseline test using initialized excerpt) These tests establish the foundation for lightweight excerpt support, which will enable renaming potential excerpts without opening them. Related: musescore#31656
Add support for saving lightweight excerpts (potential excerpts without excerptScore) in MSCZ format: - MasterScore::addLightweightExcerpt(): adds excerpt without initParts - writeLightweightExcerpt(): writes minimal XML containing only: - lightweight marker - name - tracksMapping - initialPartId - part references This enables persisting renamed potential excerpts without creating full excerptScore, reducing file size from ~16KB to ~400 bytes per lightweight excerpt. Related: musescore#31656
Add support for loading lightweight excerpts from MSCZ format: - isLightweightExcerpt(): detects lightweight format by checking for <lightweight> element in excerpt XML - readLightweightExcerpt(): parses minimal XML and reconstructs Excerpt with name, tracksMapping, initialPartId, and part references - Parts are resolved by ID from the master score's parts list Lightweight excerpts are loaded without creating excerptScore, preserving their lightweight nature until the user opens them. Related: musescore#31656
Integrate lightweight excerpt support into the notation layer: MasterNotation: - promotePotentialExcerptToLightweight(): moves ExcerptNotation from potentialExcerpts to excerpts when renamed, ensuring consistency between notation and engraving layers - initExcerptNotations(): creates ExcerptNotation without init() for lightweight excerpts - updateExcerpts(): handles lightweight excerpts in excerpt list updates ExcerptNotation: - setName(): calls promotePotentialExcerptToLightweight() for potential excerpts and marks project as unsaved NotationProject: - Skip writing viewsettings.json and audiosettings.json for lightweight excerpts (they have no meaningful settings) Related: musescore#31656
26c498e to
0aa9a45
Compare
Add null checks when iterating over excerpts to prevent crashes when lightweight excerpts (with no excerptScore) are present: NotationStyle::applyToAllParts(): - Skip excerpts without excerptScore when applying style to all parts MasterNotationParts::excerptsParts(): - Skip lightweight excerpts when collecting parts for operations MasterNotationParts::replaceInstrument(): - Handle lightweight excerpts separately when renaming excerpt after instrument replacement (use direct rename instead of undo-based) These fixes ensure that code iterating over excerpts doesn't crash when the list includes lightweight (potential) excerpts.
Add saveLightweightExcerpt test that verifies: - Lightweight excerpts can be saved to MSCZ format - Name, parts, initialPartId persist through save/reload - Excerpt remains lightweight after reload (no excerptScore) - No unnecessary files (viewsettings.json, audiosettings.json) - XML content is minimal (has <lightweight> marker, no Staff/Measure) - File size is small (< 1KB vs ~16KB for full excerpt) This test ensures the lightweight excerpt implementation works correctly end-to-end. Related: musescore#31656
When exporting parts that were temporarily initialized for export, they would remain initialized and get saved as full excerpts on subsequent save operations. This fix adds deinitExcerpts() which restores excerpts to their lightweight state after export completes. Changes: - Add ExcerptNotation::deinit() to reset excerpt to lightweight state - Add MasterNotation::deinitExcerpts() interface method - Call deinitExcerpts in export DEFER block after export completes - Make Excerpt::setInited() public for use by deinit - Add test for lightweight excerpt init/deinit cycle
0aa9a45 to
04c2133
Compare
03d4df1 to
c0dc1af
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #31656
Supersedes #31658
Summary
Part name changes in the Parts dialog now persist after save/reload, even for parts that were never opened as tabs.
This implements the "lightweight excerpts" approach suggested in the review of #31658: instead of fully initializing excerpts just to save their names, we store minimal metadata (~400 bytes) without creating a full Score (several KB per excerpt) saving resources.
Changes
Engraving layer:
MasterScore::addLightweightExcerpt()to add excerpts without initializationMscSaver(name, parts, tracksMapping, initialPartId)MscLoaderwith<lightweight>marker detectioninitParts(),rebuildExcerptsMidiMapping(), andonWriteExcerpts302()for excerpts withoutexcerptScoreExcerpt::setInited()public setter for deinit supportNotation layer:
MasterNotation::promotePotentialExcerptToLightweight()to promote renamed potential excerptsExcerptNotation::deinit()andMasterNotation::deinitExcerpts()to restore lightweight state after export