Don't remove outgoing ties when incrasing chord duration#32982
Don't remove outgoing ties when incrasing chord duration#32982MaxiSchwindler wants to merge 2 commits intomusescore:masterfrom
Conversation
📝 WalkthroughWalkthroughA refactoring that introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 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)
⚔️ Resolve merge conflicts
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4ba9b0e6-00a5-4f85-85ef-260011cde5e5
📒 Files selected for processing (5)
src/engraving/dom/noteentry.cppsrc/engraving/dom/score.cppsrc/engraving/dom/score.hsrc/engraving/editing/cmd.cppsrc/engraving/editing/edit.cpp
| Fraction endTickAfter = cr->isChord() ? toChord(cr)->endTickIncludingTied() : cr->endTick(); | ||
| while (endTickAfter < endTickBefore) { // making a chord *longer* shouldn't _shorten_ its total duration | ||
| if (!oc){ // everything up to oc should already be tied together | ||
| oc = toChord(cr1); | ||
| } | ||
|
|
||
| for (Note* n: oc->notes()){ | ||
| if (Note* nn = searchTieNote(n)){ | ||
| tieNotesTogether(n, nn); | ||
| } | ||
| } | ||
| oc = oc->next(); | ||
| endTickAfter = cr->isChord() ? toChord(cr)->endTickIncludingTied() : cr->endTick(); |
There was a problem hiding this comment.
Only recreate ties for notes that were originally tied forward.
Line 1867 currently retries every note in oc if searchTieNote() finds a match. On mixed chords, that can introduce brand-new ties on notes that were previously untied. Please capture the original outgoing-tie membership before mutating the chain and filter this loop to that subset only.
| Tie* tie = tieNotesTogether(nl1[j], nl2[j]); | ||
| ties.push_back(tie); |
There was a problem hiding this comment.
Avoid double-registering ties in undo stack.
tieNotesTogether(...) already performs undoAddElement(tie), but these ties are still re-added in the later loop at Line 1966–1969. This can create duplicate undo entries / invalid state in regrouping.
🔧 Proposed fix
@@
- Tie* tie = tieNotesTogether(nl1[j], nl2[j]);
- ties.push_back(tie);
+ ties.push_back(tieNotesTogether(nl1[j], nl2[j]));
@@
- if (tieBack[i]) {
- Tie* tie = Factory::createTie(this->dummy());
- tie->setStartNote(tieBack[i]);
- tie->setEndNote(n);
- tie->setTick(tie->startNote()->tick());
- tie->setTick2(tie->endNote()->tick());
- tie->setTrack(track);
- n->setTieBack(tie);
- tieBack[i]->setTieFor(tie);
- ties.push_back(tie);
- }
- if (tieFor[i]) {
- Tie* tie = Factory::createTie(this->dummy());
- tie->setStartNote(nn);
- tie->setEndNote(tieFor[i]);
- tie->setTick(tie->startNote()->tick());
- tie->setTick2(tie->endNote()->tick());
- tie->setTrack(track);
- nn->setTieFor(tie);
- tieFor[i]->setTieBack(tie);
- ties.push_back(tie);
- }
+ if (tieBack[i]) {
+ ties.push_back(tieNotesTogether(tieBack[i], n));
+ }
+ if (tieFor[i]) {
+ ties.push_back(tieNotesTogether(nn, tieFor[i]));
+ }
@@
- if (!ties.empty()) { // at least one tie was created
- for (Tie* tie : ties) {
- undoAddElement(tie);
- }
- connectTies();
- }
+ if (!ties.empty()) { // at least one tie was created
+ connectTies();
+ }
Resolves: #31608
Ensures that the total length of a tied chord doesn't decrease when increasing the duration of a chord contained in the tie.
Additionally, adds a
tieNotesTogetherutility method, since the more-or-less same lines were repeated a few times in the codebase. I only replaced existing code with this utility method where I was reasonably sure that its 1:1 the same; the only potential difference in some places is thatnote->setTieForandnote->setTieBackare actually called, which I assume to be what should happen anyways.Note: I made the change while on 4.7 branch, and cherry-picked to master; there were no conflicts, so this should run fine; but I haven't managed to build master yet
Summary by CodeRabbit
Release Notes