fix(oakengine): facade bugs found by integration tests
undo: - NULL/empty label no longer crosses to oakundo as a dangling 0x1 pointer (push, group_begin/end) — fixed SIGSEGV - group_abort now undoes each executed child in reverse order task: - create_project_import addrefs the borrowed project handle instead of freeing it under the async task — fixed UAF/SIGSEGV timeline: - toggle_enabled/delete_clips guard NULL+0 slices — fixed SIGABRT - BlockSplitCommand halves placed correctly (oaktimeline undosplit) - PreservingLinks / ripple remove / ripple delete-gaps commands self-prepare on first redo — fixes silent no-op split/ripple - trim_clips_to targets the block containing the point, not the track - delete_empty_tracks applies the live track removal - ripple facades no longer free borrowed track handles still referenced by commands — fixed UAF node: - project_add_node releases the factory handle — fixes per-call leak - inputs_from(recursive=0) matches direct feeders (BFS off-by-one) - group passthrough id/resolve treat two-stage string length as success - node_connect(_command) reject duplicate connects with E_STATE - folder_add_child enforces one-folder-per-node - value_split_to_tracks splits vector/color per component - set_context_position/expanded establish the first entry - node_get_flags on an empty box returns 0, not u64::MAX - footage_borrow addrefs its wrapper — fixes double-free render: - renderer_create rejects invalid pixel formats (real range check) - render_frame forwards renderer width/height to the ticket tests: repro #[ignore]s removed, bug-behavior assertions corrected, it_undo global-stack tests serialized with a shared lock
This commit is contained in:
@@ -183,6 +183,9 @@ pub struct TrackRippleRemoveAreaCommand {
|
||||
track: CHandle,
|
||||
/// Area to clear.
|
||||
range: TimeRange,
|
||||
/// Whether `prepare` has run (the C ABI command path never calls
|
||||
/// `prepare()` itself, so `redo` derives the operations on first use).
|
||||
prepared: bool,
|
||||
/// Out-point trim on the first block (`timelineundoripple.h` `trim_out_`).
|
||||
trim_out_: Option<TrimOperation>,
|
||||
/// Blocks fully inside the range to remove (`removals_`).
|
||||
@@ -224,6 +227,7 @@ impl TrackRippleRemoveAreaCommand {
|
||||
Self {
|
||||
track,
|
||||
range,
|
||||
prepared: false,
|
||||
trim_out_: None,
|
||||
removals_: Vec::new(),
|
||||
trim_in_: None,
|
||||
@@ -257,11 +261,18 @@ impl TrackRippleRemoveAreaCommand {
|
||||
|
||||
/// `prepare`: compute the trim/remove operations for the range.
|
||||
///
|
||||
/// Mirrors the C++ algorithm; the leading block lookup requires
|
||||
/// `oaknode_track_get_nearest_block_before_or_at`, which the bridge does
|
||||
/// not yet expose, so this currently finds no block and no-ops (see the
|
||||
/// module note).
|
||||
/// Mirrors the C++ algorithm (`oaknode_track_get_nearest_block_before_or_at`
|
||||
/// is exposed by the oaknode bridge; `redo` invokes this on first use
|
||||
/// because the C ABI command path never calls `prepare` itself).
|
||||
pub fn prepare(&mut self) {
|
||||
// Idempotent: recompute from the current track state, discarding any
|
||||
// previously derived operations.
|
||||
self.trim_out_ = None;
|
||||
self.removals_.clear();
|
||||
self.trim_in_ = None;
|
||||
self.insert_previous_ = CHandle::null();
|
||||
self.splice_split_command_ = None;
|
||||
|
||||
let track = hdup(&self.track);
|
||||
let in_ = self.range.in_();
|
||||
let out = self.range.out();
|
||||
@@ -351,10 +362,18 @@ impl TrackRippleRemoveAreaCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.prepared = true;
|
||||
}
|
||||
|
||||
/// `redo`: apply the ripple removal.
|
||||
pub fn redo(&mut self) {
|
||||
// The C ABI command path never invokes `prepare()` (the oakundo
|
||||
// vtable wrapper only dispatches redo/undo), so derive the operations
|
||||
// on first use.
|
||||
if !self.prepared {
|
||||
self.prepare();
|
||||
}
|
||||
if self.splice_split_command_.is_some() {
|
||||
// We're just splicing (C++ `redo_now` = prepare + redo)
|
||||
let cmd = self.splice_split_command_.as_mut().unwrap();
|
||||
@@ -905,9 +924,9 @@ impl TimelineRippleDeleteGapsAtRegionsCommand {
|
||||
|
||||
/// `prepare`: build the per-region gap-removal commands.
|
||||
///
|
||||
/// Requires the gap-kind, nearest-block, sequence-track and locked-flag
|
||||
/// queries the bridge does not yet expose, so it currently produces no
|
||||
/// commands (see the module note). The algorithm below mirrors the C++.
|
||||
/// The gap-kind, nearest-block, sequence-track and locked-flag queries
|
||||
/// all go through `bridge::node`; `redo` invokes this on first use
|
||||
/// because the C ABI command path never calls `prepare` itself.
|
||||
pub fn prepare(&mut self) {
|
||||
self.commands_.clear();
|
||||
|
||||
@@ -1070,7 +1089,14 @@ impl TimelineRippleDeleteGapsAtRegionsCommand {
|
||||
}
|
||||
|
||||
/// `redo`: apply the gap deletions.
|
||||
///
|
||||
/// The C ABI command path never invokes `prepare()` (the oakundo vtable
|
||||
/// wrapper only dispatches `redo`/`undo`), so the sub-commands are built
|
||||
/// on first use; later redos re-apply the stored commands.
|
||||
pub fn redo(&mut self) {
|
||||
if self.commands_.is_empty() {
|
||||
self.prepare();
|
||||
}
|
||||
for i in 0..self.commands_.len() {
|
||||
let c = hdup(&self.commands_[i]);
|
||||
let _ = unsafe { oakundo_command_redo_now(c) };
|
||||
|
||||
@@ -74,6 +74,12 @@ impl BlockSplitCommand {
|
||||
|
||||
/// `redo`: shrink `block` to the first half, grow `new_block` to the
|
||||
/// second half, and insert it after `block`.
|
||||
///
|
||||
/// The split keeps the ORIGINAL block anchored at its out-point (it
|
||||
/// becomes the second half `[point, out)`) and anchors the fresh
|
||||
/// `new_block` at its in-point (it becomes the first half
|
||||
/// `[in, point)`), matching the C++ `Block::set_length_and_media_out` /
|
||||
/// `set_length_and_media_in` semantics of the module.
|
||||
pub fn redo(&mut self) {
|
||||
// Create the second half if redo is invoked without a preceding
|
||||
// prepare() (the C ABI command path may call redo directly).
|
||||
@@ -89,13 +95,18 @@ impl BlockSplitCommand {
|
||||
|
||||
// The C++ asserts `point_` lies strictly inside the block; that would
|
||||
// panic across the FFI boundary, so it is intentionally not replicated.
|
||||
let new_length = self.point - block_in;
|
||||
let new_part_length = block_out - self.point;
|
||||
let first_half_length = self.point - block_in;
|
||||
let second_half_length = block_out - self.point;
|
||||
|
||||
let track = block_track(self.block.clone());
|
||||
|
||||
block_set_length_and_media_out(self.block.clone(), new_length);
|
||||
block_set_length_and_media_in(self.new_block.clone(), new_part_length);
|
||||
// Out-anchored length for the second half keeps the original's out
|
||||
// point (the C++ `set_length_and_media_out`); the in-anchored length
|
||||
// for the first half grows the fresh block from its default in of 0
|
||||
// (the C++ `set_length_and_media_in`). The two were previously
|
||||
// swapped, which anchored the halves at the wrong points.
|
||||
block_set_length_and_media_out(self.block.clone(), second_half_length);
|
||||
block_set_length_and_media_in(self.new_block.clone(), first_half_length);
|
||||
|
||||
// SAFETY: bridge inserts `new_block` after `block` on `track`.
|
||||
let _ = unsafe {
|
||||
@@ -201,7 +212,17 @@ impl BlockSplitPreservingLinksCommand {
|
||||
}
|
||||
|
||||
/// `redo`: redo every child command in order.
|
||||
///
|
||||
/// The C ABI command path never invokes `prepare()` (the oakundo vtable
|
||||
/// wrapper only dispatches `redo`/`undo`), so the children are built on
|
||||
/// first redo; `prepare` itself redoes each child as it builds it, so the
|
||||
/// first redo has nothing left to run. Later redos (after an undo) run
|
||||
/// the stored children directly.
|
||||
pub fn redo(&mut self) {
|
||||
if self.commands.is_empty() {
|
||||
self.prepare();
|
||||
return;
|
||||
}
|
||||
for c in self.commands.iter_mut() {
|
||||
c.redo();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user