Clear destination track before cloning to prevent corruption (#16896):#32833
Clear destination track before cloning to prevent corruption (#16896):#32833CubikingChill wants to merge 1 commit intomusescore:masterfrom
Conversation
| for (Segment* seg = destSeg; seg && seg->tick() < ticks; seg = seg->next1()) { | ||
| EngravingItem* el = seg->element(dtrack); | ||
| if (el && el->isChordRest()) { | ||
| s->undoRemoveElement(el); |
There was a problem hiding this comment.
We can't call undo… functions inside the undo or redo method of an UndoCommand: the undo… method causes another UndoCommand to be pushed onto the stack, which should never happen while an UndoCommand's undo or redo is performed.
There are two solutions:
- replace the
undoRemoveElementcall with something that directly removes the element, not involving the undo stack, and undo that manually inCloneVoice::undo. That's likely not possible though. - perform the
undoRemoveElementcalls outsideCloneVoice::redo, before callingscore->undo(new CloneVoice(…)).
There was a problem hiding this comment.
Let me know if the latest approach is good.
There was a problem hiding this comment.
On a superficial level, it looks correct now. I'll leave it to the team though to decide definitively whether this is the correct solution.
9de4624 to
b5c09dc
Compare
…re#16896): rests already in dtrack would otherwise coexist with the cloned notes.
b5c09dc to
c11c09b
Compare
|
Actually, it seems that I can still reproduce the corruption from #16896 (comment) after this PR, and in fact this PR does not address the root cause described there. On a closer look, it turns out that there are more pre-existing problems with I suggest putting this PR on hold, until these bigger issues are resolved. |
|
See #32850 |
|
Actually I ve read #32850 and I am quite determined to do the refactoring. Maybe I have overlooked some issues. I will let you know after there's some substantial progress. |
|
(To prevent confusion: I already did the refactoring I mentioned in the PR I mentioned, so we just need to wait for that to be merged) |
OK great. I was on my mobile github app and I didn't realize it is a PR instead of an issue. I did read the need of refactor somewhere in this repo. Do you think your refactoring will solve this issue? |
|
Although it does improve the situation somewhat, it does not fully resolve the corruption; in particular, it does not yet take into account 'ongoing' notes that start before the exploded range. |
I think you are more experienced than me in this codebase. Do you think I should continue working on this PR AFTER your PR? |
|
Yes, my PR moves a lot of stuff around, so anything that's done before my PR is merged would need to be redone because of conflicts. But indeed, after my PR is merged, you can definitely continue working on this issue. What you can already do as a preparation step, is looking how it is done for pasting, because paste operations need to do something similar (cleaning the destination area before writing new notes/rests onto it). It would be interesting to see if anything from the pasting implementation can be reused in |
Great. Looking forward to your PR being merged. Will definitely look into the areas you suggested. |
rests already in dtrack would otherwise coexist with the cloned notes.
Resolves: #16896