FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
#2358: Toggle Animation creates a parameter an older instance lacks
irgendwasmitfelixc59917baf95d
diff --git a/crates/engine/src/clip_ops_tests.rs b/crates/engine/src/clip_ops_tests.rsindex 262b1ec80..b9144a318 100644--- a/crates/engine/src/clip_ops_tests.rs+++ b/crates/engine/src/clip_ops_tests.rs@@ -1059,3 +1059,25 @@ fn linked_rate_stretch_keeps_one_speed_when_a_neighbour_blocks_the_sound() {assert!((pic.speed - sound.speed).abs() < 1e-12);assert!((r["speed"].as_f64().unwrap() - 60.0 / 70.0).abs() < 1e-9);}++/// #2358: Toggle Animation on a parameter an older effect instance lacks (it was added to the+/// effect later) creates it from its default and animates it, instead of "no such param".+#[test]+fn toggle_animation_creates_a_parameter_missing_from_an_older_instance() {+ let mut s = crate::Session::default();+ s.execute("file.openDemoProject", serde_json::json!({})).unwrap();+ let seq = s.state.active_sequence.unwrap();+ let clip = s.active_sequence().unwrap().video_tracks[0].items[0].id;+ // an older project: Motion without its Rotation entry+ {+ let p = std::sync::Arc::make_mut(&mut s.project);+ let q = p.sequence_mut(seq).unwrap();+ let (_, it) = q.find_item_mut(clip).unwrap();+ 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();+ 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.rsindex f7737f571..3223479a3 100644--- a/crates/engine/src/commands.rs+++ b/crates/engine/src/commands.rs@@ -3111,6 +3111,14 @@ fn build() -> Vec<CommandSpec> {_ => None,}.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()+ && !e.params.contains_key(&pid)+ && let Some(d) = e.def().and_then(|d| d.param(&pid))+ {+ e.params.insert(pid.clone(), filmcraft_project::Param::new(d.default.clone()));+ }crate::masks::target_param(e, p, &pid).ok_or_else(|| bad("effects.toggleAnimation", "no such param"))?.toggle_animation(mt);Ok(())})?;