Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

#2358: "mask": null counts as no mask when creating a missing parameter

irgendwasmitfelixaa918e739f97
diff --git a/crates/engine/src/clip_ops_tests.rs b/crates/engine/src/clip_ops_tests.rs
index b9144a318..940c00af5 100644
--- a/crates/engine/src/clip_ops_tests.rs
+++ b/crates/engine/src/clip_ops_tests.rs
@@ -1076,7 +1076,8 @@ fn toggle_animation_creates_a_parameter_missing_from_an_older_instance() {
let m = it.effects.iter_mut().find(|e| e.effect == "motion").unwrap();
m.params.remove("rotation");
}
- s.execute("effects.toggleAnimation", serde_json::json!({"clip": clip.0, "effect": "motion", "param": "rotation"})).unwrap();
+ // `"mask": null` is no mask, as in effects.setParam
+ s.execute("effects.toggleAnimation", serde_json::json!({"clip": clip.0, "effect": "motion", "param": "rotation", "mask": null})).unwrap();
let it = s.active_sequence().unwrap().find_item(clip).unwrap().1.clone();
let rot = it.effect("motion").unwrap().param("rotation").unwrap();
assert!(rot.is_animated(), "the stopwatch is on");
diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs
index 3223479a3..4d11d9c55 100644
--- a/crates/engine/src/commands.rs
+++ b/crates/engine/src/commands.rs
@@ -3113,7 +3113,7 @@ fn build() -> Vec<CommandSpec> {
.ok_or_else(|| bad("effects.toggleAnimation", "no such effect"))?;
// a parameter an older instance lacks (added to the effect later) starts from its
// default, as the UI shows it, without touching an existing one
- if p.get("mask").is_none()
+ if p.get("mask").is_none_or(Value::is_null)
&& !e.params.contains_key(&pid)
&& let Some(d) = e.def().and_then(|d| d.param(&pid))
{