Skip to content

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

Merge pull request #863 from itrycodinganditsbad/fix-748

Brandon Thomas3f8af1a3b6c3
diff --cc crates/engine/src/commands/file.rs
index 301e59bf4,9c49c28c2..74ec861e2
--- a/crates/engine/src/commands/file.rs
+++ b/crates/engine/src/commands/file.rs
@@@ -43,18 -43,11 +43,19 @@@ pub(crate) fn open(s: &mut Session, p:
let text = String::from_utf8(bytes).map_err(|_| EngineError::Other("not a text project file".into()))?;
// XML copies (File ▸ Save a Copy As XML…) open like the JSON project.
let text = if crate::xml_project::is_xml(&text) { crate::xml_project::from_xml(&text).map_err(EngineError::Other)? } else { text };
- let mut proj = Project::from_json(&text).map_err(|e| EngineError::Other(format!("{path} is not a project EffectCraft can open: {e}")))?;
+ let (mut proj, repaired) =
+ Project::from_json_repaired(&text).map_err(|e| EngineError::Other(format!("{path} is not a project EffectCraft can open: {e}")))?;
resolve_relative_footage(&mut proj, path, s.services.as_ref());
s.replace_project(proj, Some(path.to_string()));
+ s.restore_view(&effectcraft_project::saved_view(&text));
s.note_project_path(path);
+ // Values past the limits (a corrupt or hostile file) were brought within them (#788).
+ if !repaired.is_empty() {
+ let more = repaired.len().saturating_sub(3);
+ let shown = repaired.iter().take(3).cloned().collect::<Vec<_>>().join("; ");
+ let more = if more > 0 { format!(" and {more} more") } else { String::new() };
+ s.toast(format!("This project had values outside EffectCraft's limits, corrected when it opened: {shown}{more}."));
+ }
// Written by a newer EffectCraft: what this version doesn't know would be lost on saving.
let saved_by = effectcraft_project::saved_by(&text);
if let Some(v) = saved_by.as_deref().filter(|v| effectcraft_project::is_newer_version(v, effectcraft_project::APP_VERSION)) {