Fix appendPart not applying tablature staff type from template#33821
Fix appendPart not applying tablature staff type from template#33821knoguchi wants to merge 1 commit into
Conversation
Score::appendPart(const InstrumentTemplate*) was passing the freshly- created default StaffType into Staff::init as the explicit preset, which shadowed t->staffTypePreset and forced every appended staff to a default standard 5-line, breaking tablature templates via the plugin API. Passing nullptr lets Staff::init fall through to t->staffTypePreset, as the post-musescore#29478 refactor intended. Adds regression tests: - AppendPartFromTablatureTemplate: asserts appendPart of a TAB instrument yields a TAB-group, 6-line staff. - AppendPartFromStandardTemplatePreservesClefs: asserts piano gets treble + bass default clefs across its two staves.
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsLinked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped 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. Comment |
Resolves: #33820
Summary
Score::appendPart(const InstrumentTemplate*)was passing the freshly-created default StaffType intoStaff::initas the explicit preset, which shadowedt->staffTypePresetand forced every appended staff to a default standard 5-line — breaking tablature templates via the plugin API.Passing
nullptrletsStaff::initfall through tot->staffTypePreset, as the post-#29478 refactor intended.Prior attempt
#29478 (commit
451b451bd8, "Set default clefs when creating parts") was the first attempt at this consolidation: it correctly replaced the old hand-rolled body ofappendPartwith a delegation toStaff::init. But it left the vestigialstt = staff->staffType(Fraction(0, 1))local from the previous body and threaded it into the newinitcall. SinceFactory::createStaffconstructs a Staff with the default STANDARD preset already assigned, that pointer is non-null andStaff::inittakes theif (staffType)branch, shadowingt->staffTypePresetand defeating the refactor's intent.This PR drops the stale local and passes
nullptrinstead, finishing what #29478 started.Changes
src/engraving/dom/score.cpp: drop the vestigialsttlocal; passnullptrtoStaff::initso the template'sstaffTypePresetwins.src/engraving/tests/scoreutils_tests.cpp: two regression testsAppendPartFromTablatureTemplate— appending theguitar-nylon-tablaturetemplate yields a TAB-group, 6-line staff.AppendPartFromStandardTemplatePreservesClefs— appending thepianotemplate still yields the per-staff treble + bass default clefs.Local validation
sttlocal.