Skip to content

Project migration refactor - #34873

Open
miiizen wants to merge 4 commits into
musescore:mainfrom
miiizen:projectMigrationRefactor
Open

Project migration refactor#34873
miiizen wants to merge 4 commits into
musescore:mainfrom
miiizen:projectMigrationRefactor

Conversation

@miiizen

@miiizen miiizen commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

These migrations must happen to every <4.0 score, so they should go in our usual score compatibility files. These migrations were skipped for vtests, leading to scores looking different in the test and in the application (which was causing a lot of headaches when working on offsets migrations).

The vtests should now match what we see when scores are opened in MuseScore.

miiizen and others added 3 commits September 9, 2026 17:17
These migrations must happen to every <4.0 score, so they should go in our usual score compatibility files. These migrations were skipped for vtests, leading to scores looking different in the test and in the application.
It is already called in `MscLoader::loadMscz`, so no need to call it in individual reader implementations.
It serves no purpose and meta tags are not the place for `mscVersion`.
@miiizen
miiizen requested a review from ajuncosa September 9, 2026 16:22
@miiizen miiizen added the vtests This PR produces approved changes to vtest results label Sep 9, 2026
@miiizen

miiizen commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@cbjeukendrup sorry - I only remembered #32847 halfway through this. I've cherry picked a couple of the most relevant commits. Please feel free to review!

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 5ef27da9-8d68-4013-8e48-d5a0ae165c58

📥 Commits

Reviewing files that changed from the base of the PR and between ea47421 and f940e38.

📒 Files selected for processing (3)
  • src/engraving/compat/engravingcompat.cpp
  • src/engraving/compat/engravingcompat.h
  • src/engraving/style/style.cpp
💤 Files with no reviewable changes (1)
  • src/engraving/style/style.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change moves legacy engraving resets from project migration into compatibility processing. Older scores now reset element positions and cross-staff beams through EngravingCompat. Reset::resetAllPositions performs element-level resets. Legacy Score reset APIs and migration methods are removed. Style compatibility values are applied for scores before version 4.00. Migration style versions and demo metadata are updated. MuseScore 2.06 reading no longer performs the removed compatibility conversion.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f940e

The compatibility migration introduces no verified merge-blocking behavior change.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the migration change and its motivation, but it omits the required issue reference and all checklist items from the repository template. Add a Resolves issue reference and complete the required checklist. Confirm the CLA, title, commit messages, coding rules, testing, prior attempts, unnecessary changes, and applicable unit or vtest coverage.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change as a refactor of project migration logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/muse_framework.git.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cbjeukendrup cbjeukendrup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for notifying me! Yes, this looks good to me. One small tidiness comment.

The other two commits from #32847 are probably also still worth porting, but that can be done in a different PR.


int mscVersion = score->mscVersion();

if (score->mscVersion() < 300) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (score->mscVersion() < 300) {
if (mscVersion < 300) {

(same for 206)

Also, maybe it is nice to keep the version checks in some order, like oldest migrations first or last.

Comment thread src/engraving/style/style.cpp Outdated
Comment on lines +425 to +437
double doubleBarDistance = styleAbsolute(mu::engraving::Sid::doubleBarDistance);
doubleBarDistance -= styleAbsolute(mu::engraving::Sid::doubleBarWidth);
set(Sid::doubleBarDistance, doubleBarDistance / sp);
double endBarDistance = styleAbsolute(mu::engraving::Sid::endBarDistance);
endBarDistance -= (styleAbsolute(mu::engraving::Sid::barWidth) + styleAbsolute(Sid::endBarWidth)) / 2;
set(Sid::endBarDistance, endBarDistance / sp);
double repeatBarlineDotSeparation = styleAbsolute(mu::engraving::Sid::repeatBarlineDotSeparation);
static std::shared_ptr<IEngravingFontsProvider> engravingFonts
= muse::modularity::globalIoc()->resolve<IEngravingFontsProvider>("engraving");
double dotWidth = engravingFonts->fontByName(value(Sid::musicalSymbolFont).value<String>().toStdString())->width(
mu::engraving::SymId::repeatDot, 1.0);
repeatBarlineDotSeparation -= (styleAbsolute(mu::engraving::Sid::barWidth) + dotWidth) / 2;
set(Sid::repeatBarlineDotSeparation, repeatBarlineDotSeparation / sp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These styles are re-calculated relative to their last value every time this function is called. I believe the function may be called multiple times (e.g. for 3.x scores, it would be called once while reading the legacy-style-defaults-vX.mss file, and then again while reading the score style - or more if there are user styles, I guess), so the values would accumulate. Before, these were only calculated and overwritten once during project migration.

Not sure what the best solution would be, maybe moving it out of the MStyle::read, to after the entire score is read (e.g. EngravingCompat)? Or adding some sort of guard?

Comment thread src/engraving/style/style.cpp Outdated
set(Sid::tiePlacementChord, TiePlacement::INSIDE);
}

if (mscVersion < 400 && !MScore::testMode) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

applyCompatStyleVals is being called by ReadStyleHook::readStyleTag (in read302 and later), but I believe Read206 and Read114 read style through their own functions so they may not get these migrations (the function is called when reading the legacy-style-defaults-vX.mss file, so effect may vary depending on whether the styles were explicitly set in the score or not?)


bool EngravingCompat::resetAllElementsPositions(MasterScore* score)
{
for (Score* score : score->scoreList()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick but may be worth changing the name of this scope's score so it's not the same as the function parameter (same in line 454).

Transaction& tx = score->transactionManager()->currentOrDummyTransaction();
Reset::resetAllPositions(tx, score);
}
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May be intended, but this doesn't seem to ever return false (same in resetAllCrossBeams). Maybe needRelayout can be explicitly set i doPostLayoutCompatIfNeeded instead.

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

Labels

vtests This PR produces approved changes to vtest results

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants