Fix chord symbols alignment when multiple staves have chord symbols#32811
Fix chord symbols alignment when multiple staves have chord symbols#32811cbjeukendrup wants to merge 2 commits intomusescore:masterfrom
Conversation
cd34692 to
5baef5b
Compare
miiizen
left a comment
There was a problem hiding this comment.
Thank you! Looks good to me, I've just added a vtest.
📝 WalkthroughWalkthroughUpdated duplicate-detection logic in harmony and fret diagram layout methods to track both tick position and staff index as a pair, replacing individual tick-only tracking. This enables correct alignment of chord symbols across multiple staves within a system. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/engraving/rendering/score/systemlayout.cpp (1)
1123-1127:⚠️ Potential issue | 🟠 MajorFix the incomplete erase-remove idiom in two locations.
Lines 1126 and 1144 use an incomplete form of the erase-remove idiom. The
std::remove()call moves matching elements to the end and returns an iterator, buterase()must be called with both the iterator and the container's end to remove the entire moved range. Currently, only one element is erased; if the sameHarmony*appears twice, one copy survives and can still participate in alignment logic. This creates silent correctness issues in harmony placement.Suggested fix
if (muse::contains(fretHarmonyPositions, { fd->tick(), fd->staffIdx() })) { fretOrHarmonyItemsNoAlign.push_back(fd); if (fd->harmony()) { - harmonyItemsAlign.erase(std::remove(harmonyItemsAlign.begin(), harmonyItemsAlign.end(), fd->harmony())); + harmonyItemsAlign.erase( + std::remove(harmonyItemsAlign.begin(), harmonyItemsAlign.end(), fd->harmony()), + harmonyItemsAlign.end()); fretOrHarmonyItemsNoAlign.push_back(fd->harmony()); } continue; @@ if (muse::contains(fretHarmonyPositions, { h->tick(), h->staffIdx() })) { - harmonyItemsAlign.erase(std::remove(harmonyItemsAlign.begin(), harmonyItemsAlign.end(), h)); + harmonyItemsAlign.erase( + std::remove(harmonyItemsAlign.begin(), harmonyItemsAlign.end(), h), + harmonyItemsAlign.end()); fretOrHarmonyItemsNoAlign.push_back(h); continue; }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 43c984a2-3018-4f38-92d0-dcc5d44ca0bf
📒 Files selected for processing (2)
src/engraving/rendering/score/systemlayout.cppvtest/scores/harmony-align-2.mscz
Resolves: #31927
Follow-up to #29745
Summary by CodeRabbit