Skip to content

Fix edit algorithms deleting the wrong child via remove_child(<pointer>)#2025

Open
TroyHernandez wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
TroyHernandez:fix/edit-algo-remove-child-wrong-index
Open

Fix edit algorithms deleting the wrong child via remove_child(<pointer>)#2025
TroyHernandez wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
TroyHernandez:fix/edit-algo-remove-child-wrong-index

Conversation

@TroyHernandez
Copy link
Copy Markdown

Composition only declares remove_child(int index, ErrorStatus*), but overwrite() and insert() in editAlgorithm.cpp 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.

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.
  • Transition removal in 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 covers M and fully covers B to the track end:

before (buggy):  A[0+5] B[20+5] X[2+10]   # M removed, B kept — wrong
after  (fixed):  A[0+5] M[10+3] X[2+10]   # M trimmed, B removed — correct

Fix

Pass the already-computed (and bounds-checked) index for transitions, and index_of_child(items.back()) in the removal loop.

Tests

  • Adds test_edit_overwrite_partial_first_full_last, which fails before this change and passes after.
  • The existing test_editAlgorithm suite 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).

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>
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jun 7, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: TroyHernandez / name: Troy Hernandez (8680cd2)

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.50%. Comparing base (6944f10) to head (8680cd2).

Files with missing lines Patch % Lines
src/opentimelineio/algo/editAlgorithm.cpp 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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              
Flag Coverage Δ
py-unittests 84.50% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/opentimelineio/algo/editAlgorithm.cpp 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6944f10...8680cd2. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants