Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #7262: fix(atn): reject numeric layer references in .atn export (#7248)

aiongg624c9b743e77
diff --cc crates/engine/src/jobs.rs
index 4c3d63297,c98266205..9ea1a2413
--- a/crates/engine/src/jobs.rs
+++ b/crates/engine/src/jobs.rs
@@@ -212,10 -212,7 +212,11 @@@ struct Running
label: String,
params: Value,
journal: bool,
+ /// The recording (`ActionState::take`) running when the job started, if any (set by
+ /// `dispatch`, once recording resumes). Only that recording gets the job's step: one started
+ /// later must not pick up an edit made before it.
+ recorded_by: Option<u64>,
+ pre_selected: Option<Vec<LayerId>>,
doc: Option<DocId>,
/// The document as the job saw it: applying fails if it was edited meanwhile.
snapshot: Option<Weak<Document>>,
@@@ -404,7 -401,7 +405,8 @@@ pub fn run<T: Send + 'static>
label: label.to_string(),
params: Value::Null,
journal: true,
+ recorded_by: None,
+ pre_selected: None,
doc,
snapshot,
ctx,
@@@ -814,7 -783,7 +817,8 @@@ impl Session
job.command = id.to_string();
job.params = params;
job.journal = spec.journal;
+ job.recorded_by = self.actions.recording.map(|_| self.actions.take);
+ job.pre_selected = pre_selected.clone();
let jid = job.id;
self.jobs.running.push(job);
Ok(Started::Job(jid))
@@@ -823,18 -792,7 +827,18 @@@
if let Some(before) = before {
self.add_relayout_damage(&before);
}
+ if let Some((doc_id, layer_id)) = new_fx_target
+ && let Some(st) = self.active_mut()
+ && st.doc.id == doc_id
+ && st.doc.layer(layer_id).is_some_and(|l| !l.effects.items.is_empty())
+ {
+ if expand_new_fx {
+ st.fx_collapsed.retain(|id| *id != layer_id);
+ } else if !st.fx_collapsed.contains(&layer_id) {
+ st.fx_collapsed.push(layer_id);
+ }
+ }
- self.after_command(id, params, spec.journal, Some(nested_from));
+ self.after_command(id, params, spec.journal, Some(nested_from), pre_selected.as_deref());
Ok(Started::Done(v))
}
}
@@@ -912,15 -869,8 +915,15 @@@
};
self.end_job(&job, outcome);
}
+
fn apply_job(&mut self, job: &Running, apply: Option<Apply>, payload: Payload) -> Result<Value> {
- let Running { label, doc, snapshot, coalesce, color_restrict, layers, command, params, journal, recorded_by, .. } = job;
- let Running { label, doc, snapshot, coalesce, color_restrict, layers, command, params, journal, pre_selected, .. } = job;
++ let Running { label, doc, snapshot, coalesce, color_restrict, layers, command, params, journal, recorded_by, pre_selected, .. } = job;
+ // A recording started after the job (#7289) keeps what it has so far, and the job's step
+ // goes into the journal past its start, so that recording doesn't get it.
+ let foreign = self.actions.recording.is_some() && *recorded_by != Some(self.actions.take);
+ if foreign {
+ crate::actions_cmds::flush_recording(self)?;
+ }
let prev_active = self.active;
let target = match doc {
Some(d) => {
@@@ -968,10 -918,7 +971,10 @@@
// Restoring the viewed document first would attribute Fade and slice updates
// to that document instead, when the user switched tabs mid-job.
if r.is_ok() {
- self.after_command(command, params.clone(), *journal, Some(nested_from));
+ self.after_command(command, params.clone(), *journal, Some(nested_from), pre_selected.as_deref());
+ if foreign && let Some((start, _)) = self.actions.recording.as_mut() {
+ *start = self.journal.len();
+ }
}
// Give the user back the layers they selected while the job ran, unless the job chose a
// selection itself (a new layer, say) or one of their layers is gone.