Fix edit algorithms deleting the wrong child via remove_child(<pointer>)#2025
Open
TroyHernandez wants to merge 1 commit into
Open
Conversation
Composition only declares `remove_child(int index, ErrorStatus*)`, but
`overwrite()` and `insert()` call it with a `Composable*` / `Retainer`:
composition->remove_child(transition); // overwrite() and insert()
composition->remove_child(items.back()); // overwrite()
The pointer argument decays to `bool` (always true) -> `int(1)`, so these calls
remove the child at index 1 (or, via adjusted_vector_index, the last child when
size == 1), NOT the item that was passed. As a result:
- overwrite() over a multi-item span deletes the wrong clips: the
partially-overwritten clip is removed while a fully-overwritten clip survives.
- transition removal in overwrite()/insert() removes index 1 instead of the
transition.
Pass the already-computed (and bounds-checked) `index` for transitions, and the
index of `items.back()` in the removal loop.
Repro (overwrite A|M|B with X over a span that ends at the track end):
before: A[0+5] B[20+5] X[2+10] (M removed, B kept -- wrong)
after: A[0+5] M[10+3] X[2+10] (M trimmed, B removed -- correct)
Adds a regression test (fails before, passes after); the existing
test_editAlgorithm suite continues to pass.
Signed-off-by: Troy Hernandez <troy.hernandez@pm.me>
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2025 +/- ##
==========================================
- Coverage 84.51% 84.50% -0.01%
==========================================
Files 181 181
Lines 13239 13240 +1
Branches 1202 1202
==========================================
Hits 11189 11189
- Misses 1867 1868 +1
Partials 183 183
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Composition only declares
remove_child(int index, ErrorStatus*), butoverwrite()andinsert()ineditAlgorithm.cppcall it with aComposable*/Retainer:The pointer argument decays to
bool(alwaystrue) →int(1), so these calls remove the child at index 1 (or, viaadjusted_vector_index, the last child whensize() == 1), not the item that was passed.Impact
overwrite()over a multi-item span deletes the wrong clips: the partially-overwritten clip is removed while a fully-overwritten clip survives in place.overwrite()/insert()removes index 1 instead of the intended transition.Repro
Track
A|M|B(each 5/8/5 frames),overwrite(X, track, [8, 18))— a span that partially coversMand fully coversBto the track end:Fix
Pass the already-computed (and bounds-checked)
indexfor transitions, andindex_of_child(items.back())in the removal loop.Tests
test_edit_overwrite_partial_first_full_last, which fails before this change and passes after.test_editAlgorithmsuite continues to pass.I verified the fix and the regression test by building the library locally (the test fails on the unfixed tree, passes on the fixed tree).