Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Settings: older settings files split layers above the original (#2545)

bflatastic561c2a8e48d2
diff --git a/crates/engine/src/settings/prefs.rs b/crates/engine/src/settings/prefs.rs
index d2db7cd55..94c90c3a3 100644
--- a/crates/engine/src/settings/prefs.rs
+++ b/crates/engine/src/settings/prefs.rs
@@ -36,7 +36,7 @@ pub use sections::{
use sections::{Extra, default_labels, lenient_comp_presets};
/// Current settings layout version.
-pub const PREFS_VERSION: u32 = 3;
+pub const PREFS_VERSION: u32 = 4;
/// Settings file name in the config store.
pub const PREFS_FILE: &str = "prefs.json";
diff --git a/crates/engine/src/settings/prefs/document.rs b/crates/engine/src/settings/prefs/document.rs
index d82205352..1f68c4a06 100644
--- a/crates/engine/src/settings/prefs/document.rs
+++ b/crates/engine/src/settings/prefs/document.rs
@@ -9,6 +9,8 @@ use super::{Appearance, General, Map, PREFS_VERSION, Prefs, Startup, Value, json
/// `autoSaveMinutes`, `autoSaveVersions`, `labelNames` (array) and `theme` at the top level.
/// - version 2 defaulted the disk cache to 100 GB, more than most laptops have free; the stored
/// old default becomes the new one (a size the user chose is kept).
+/// - version 3 and earlier could still hold `createSplitLayersAbove: false`, the default before
+/// #2083 (every save kept it); it becomes After Effects' default, above (#2545).
pub fn migrate(mut v: Value) -> Value {
let Some(obj) = v.as_object_mut() else { return json!({}) };
let version = obj.get("version").and_then(Value::as_u64).unwrap_or(0);
@@ -42,6 +44,12 @@ pub fn migrate(mut v: Value) -> Value {
{
d.insert("diskCacheMaxGb".into(), json!(20));
}
+ if version < 4
+ && let Some(g) = obj.get_mut("general").and_then(Value::as_object_mut)
+ && g.get("createSplitLayersAbove") == Some(&json!(false))
+ {
+ g.insert("createSplitLayersAbove".into(), json!(true));
+ }
// Settings saved before appearance modes had one theme: keep showing it, as a fixed Dark or
// Light mode, instead of switching established users to Auto.
if let Some(a) = obj.get_mut("appearance").and_then(Value::as_object_mut)
diff --git a/crates/engine/src/tests/settings.rs b/crates/engine/src/tests/settings.rs
index f2fd5a3b7..79e9fa727 100644
--- a/crates/engine/src/tests/settings.rs
+++ b/crates/engine/src/tests/settings.rs
@@ -79,6 +79,15 @@ fn prefs_migrate_old_disk_cache_default() {
assert_eq!(Prefs::from_json(r#"{"version": 3, "disk": {"diskCacheMaxGb": 100}}"#).disk.disk_cache_max_gb, 100);
}
+#[test]
+fn prefs_migrate_old_split_layers_default() {
+ // Settings saved before #2083 kept "below"; they move to After Effects' "above" once (#2545).
+ let above = |doc: &str| Prefs::from_json(doc).general.create_split_layers_above;
+ assert!(above(r#"{"version": 3, "general": {"createSplitLayersAbove": false}}"#));
+ assert!(above(r#"{"version": 2, "general": {"createSplitLayersAbove": false}}"#));
+ assert!(!above(r#"{"version": 4, "general": {"createSplitLayersAbove": false}}"#), "a choice made since stays");
+}
+
#[test]
fn prefs_set_validates_keys_types_and_ranges() {
let mut p = Prefs::default();