EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
M3.9: an edit that only allocates ids still counts as a change
bflatastica965d8df4921
diff --git a/crates/project/src/lib.rs b/crates/project/src/lib.rsindex a2e850899..36cbe7ed5 100644--- a/crates/project/src/lib.rs+++ b/crates/project/src/lib.rs@@ -1104,9 +1104,9 @@ impl Project {}self.next_id = m;}- /// Whether `other` holds the same content (ids allocated but not used don't count). Shared- /// compositions compare by pointer first, so after a copy-on-write edit only the comps it- /// touched are compared field by field.+ /// Whether `other` holds the same content. An allocated id counts (an edit may hand it out+ /// beyond the project, so it must stay taken). Shared compositions compare by pointer first,+ /// so after a copy-on-write edit only the comps it touched are compared field by field.pub fn same_content(&self, other: &Project) -> bool {let item_eq = |a: &Item, b: &Item| {let kind = match (&a.kind, &b.kind) {@@ -1116,6 +1116,7 @@ impl Project {kind && a.id == b.id && a.name == b.name && a.label == b.label && a.comment == b.comment && a.parent == b.parent && a.proxy == b.proxy};self.schema == other.schema+ && self.next_id == other.next_id&& self.settings == other.settings&& self.items.len() == other.items.len()&& self.items.iter().zip(&other.items).all(|((ka, a), (kb, b))| ka == kb && item_eq(a, b))diff --git a/crates/project/src/tests.rs b/crates/project/src/tests.rsindex 514a2fc4d..edf9a2567 100644--- a/crates/project/src/tests.rs+++ b/crates/project/src/tests.rs@@ -86,12 +86,13 @@ fn camera_and_light_layers_build() {}#[test]-fn same_content_ignores_unused_ids_and_sees_comp_edits() {+fn same_content_sees_allocated_ids_and_comp_edits() {let (p, cid) = project_with_layer();let mut q = p.clone();assert!(q.same_content(&p));q.alloc();- assert!(q.same_content(&p), "an allocated but unused id is not a change");+ assert!(!q.same_content(&p), "an allocated id stays taken");+ let mut q = p.clone();// A comp copied on write but left equal is the same; a changed one is not.let _ = q.comp_mut(cid).unwrap();assert!(q.same_content(&p));