refactor(undo): switch oakundo to refcounted value handles, migrate consumers

- OakUndoCommand/OakUndoStack become neutral by-value handles
  {ctx, addref, release, abi_version}; a handle is a shared_ptr
  equivalent at the ABI level, internals untouched (box owns/observes
  flag; containers adopt, boxes created by factories own)
- oaknode command factories and undoable variants return/write value
  handles; timeline command classes hold value handles; task import
  take_command returns a value handle
- tests updated everywhere; suites green: oakundo 22, oaktimeline 117,
  oaktask 106, oaknode 96, oakrender 44, oakcodec 18, oakcommon 193,
  oakaudio 36
This commit is contained in:
2026-08-07 15:48:34 +08:00
parent da2ab512c6
commit 295ea1bfe5
41 changed files with 837 additions and 684 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ OakNodeNode *oaknode_folder_as_node(OakNodeFolder *folder);
* @brief Create an undoable FolderAddChild command. Owned; free with
* oakundo_command_free().
*/
OakUndoCommand *oaknode_command_create_folder_add_child(
OakUndoCommand oaknode_command_create_folder_add_child(
OakNodeFolder *folder, OakNodeNode *child);
/**
+2 -2
View File
@@ -88,7 +88,7 @@ int oaknode_group_add_input_passthrough_undoable(OakNodeGroup *group,
OakNodeNode *node,
const char *input_id,
int element,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Remove the passthrough for (`node`, `input_id`, `element`)
@@ -137,7 +137,7 @@ int oaknode_group_set_output_passthrough(OakNodeGroup *group,
* (olive::NodeGroupSetOutputPassthrough).
*/
int oaknode_group_set_output_passthrough_undoable(
OakNodeGroup *group, OakNodeNode *node, OakUndoCommand **out_command);
OakNodeGroup *group, OakNodeNode *node, OakUndoCommand *out_command);
/**
* @brief Resolve an input through group passthroughs
+5 -5
View File
@@ -109,7 +109,7 @@ int oaknode_keyframe_set_time(OakNodeKeyframe *keyframe, int64_t time_num,
*/
int oaknode_keyframe_set_time_undoable(OakNodeKeyframe *keyframe,
int64_t time_num, int64_t time_den,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Read the keyframe's value mapped into `out`. Values without a
@@ -132,7 +132,7 @@ int oaknode_keyframe_set_value(OakNodeKeyframe *keyframe,
*/
int oaknode_keyframe_set_value_undoable(OakNodeKeyframe *keyframe,
const oaknode_value *v,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Read a string value. Two-stage getter.
@@ -154,7 +154,7 @@ int oaknode_keyframe_set_value_string(OakNodeKeyframe *keyframe,
*/
int oaknode_keyframe_set_value_string_undoable(OakNodeKeyframe *keyframe,
const char *value,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief The keyframe's interpolation type (oaknode_keyframe_type).
@@ -171,7 +171,7 @@ int oaknode_keyframe_set_type(OakNodeKeyframe *keyframe, int type);
* @brief Create a set-type command (same semantics as the live variant).
*/
int oaknode_keyframe_set_type_undoable(OakNodeKeyframe *keyframe, int type,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief A bezier control point (`handle` is an
@@ -192,7 +192,7 @@ int oaknode_keyframe_set_bezier_control(OakNodeKeyframe *keyframe, int handle,
*/
int oaknode_keyframe_set_bezier_control_undoable(OakNodeKeyframe *keyframe,
int handle, double x, double y,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief The keyframe's track index.
+13 -13
View File
@@ -171,7 +171,7 @@ int oaknode_node_set_label(OakNodeNode *node, const char *label);
* @return OAKNODE_OK or a negative OAKNODE_E_* error code.
*/
int oaknode_node_set_label_undoable(OakNodeNode *node, const char *label,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief The node's override color index (Node::get_override_color();
@@ -196,7 +196,7 @@ int oaknode_node_set_override_color(OakNodeNode *node, int index);
* @return OAKNODE_OK or a negative OAKNODE_E_* error code.
*/
int oaknode_node_set_override_color_undoable(OakNodeNode *node, int index,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief 1 if the node is enabled (the boolean "enabled_in" input's
@@ -220,7 +220,7 @@ int oaknode_node_set_enabled(OakNodeNode *node, int enabled);
* @return OAKNODE_OK or a negative OAKNODE_E_* error code.
*/
int oaknode_node_set_enabled_undoable(OakNodeNode *node, int enabled,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/* ---- Input introspection ------------------------------------------------ */
@@ -310,7 +310,7 @@ int oaknode_node_set_input(OakNodeNode *node, const char *input_id,
*/
int oaknode_node_set_input_undoable(OakNodeNode *node, const char *input_id,
const oaknode_value *v,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Read a string-family input's standard value. Two-stage getter.
@@ -331,7 +331,7 @@ int oaknode_node_set_input_string(OakNodeNode *node, const char *input_id,
int oaknode_node_set_input_string_undoable(OakNodeNode *node,
const char *input_id,
const char *value,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/* ---- Graph editing -------------------------------------------------------- */
@@ -356,7 +356,7 @@ int oaknode_node_connect(OakNodeNode *output_node, OakNodeNode *input_node,
int oaknode_node_connect_undoable(OakNodeNode *output_node,
OakNodeNode *input_node,
const char *input_id,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Remove the edge feeding `input_node`'s `input_id` directly
@@ -371,7 +371,7 @@ int oaknode_node_disconnect(OakNodeNode *input_node, const char *input_id);
*/
int oaknode_node_disconnect_undoable(OakNodeNode *input_node,
const char *input_id,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Number of outgoing edges (Node::output_connections()).
@@ -422,7 +422,7 @@ int oaknode_node_unlink(OakNodeNode *a, OakNodeNode *b, int *out_unlinked);
* `link` != 0 links, 0 unlinks).
*/
int oaknode_node_link_undoable(OakNodeNode *a, OakNodeNode *b, int link,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief 1 if the two nodes are linked (Node::are_linked()).
@@ -477,7 +477,7 @@ int oaknode_node_set_context_position(OakNodeNode *node, OakNodeNode *context,
int oaknode_node_set_context_position_undoable(OakNodeNode *node,
OakNodeNode *context, double x,
double y, int expanded,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Remove the node from `context` directly (live).
@@ -504,7 +504,7 @@ OakNodeNode *oaknode_node_create_copy(const OakNodeNode *node);
* until then. Returns NULL on failure.
*/
OakNodeNode *oaknode_node_copy_in_graph(OakNodeNode *node,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Get the project this node belongs to (borrowed). *out may be
@@ -537,7 +537,7 @@ int oaknode_node_disconnect_element(OakNodeNode *input_node,
* @brief Create a command that adds a node to a project's graph
* (olive::NodeAddCommand). Owned; free with oakundo_command_free().
*/
OakUndoCommand *oaknode_command_create_add_node(OakNodeProject *graph,
OakUndoCommand oaknode_command_create_add_node(OakNodeProject *graph,
OakNodeNode *node);
/**
@@ -545,7 +545,7 @@ OakUndoCommand *oaknode_command_create_add_node(OakNodeProject *graph,
* repositions its dependencies recursively
* (olive::NodeSetPositionAndDependenciesRecursivelyCommand). Owned.
*/
OakUndoCommand *oaknode_command_create_set_position_recursive(
OakUndoCommand oaknode_command_create_set_position_recursive(
OakNodeNode *node, OakNodeNode *context, double x, double y);
/**
@@ -607,7 +607,7 @@ int oaknode_node_find_input_footage(const OakNodeNode *node,
* Owned command handle; free with oakundo_command_free(). Returns NULL
* on failure.
*/
OakUndoCommand *oaknode_command_create_remove_node(OakNodeNode *node);
OakUndoCommand oaknode_command_create_remove_node(OakNodeNode *node);
/**
* @brief Destroy an OWNED node immediately (C++ delete). NULL is a no-op.