Protect a paused Menu Item from Actions library changes

This commit is contained in:
yoriswind committed 2026-11-08 04:30:47 -08:00
1 parent ad43e80164
commit 40c68d3bfc
2 files changed
+15 -5

No files matched your search

+5 -1
View File
@@ -57,7 +57,11 @@ pub(crate) fn idle(app: &PhotocraftApp, command: &str) -> Result<(), String> {
if app.services.preset_store.is_some() {
return Err(tl!("Wait for the Actions library to load.").into());
}
if app.session.actions.recording.is_some() || app.session.actions.playing > 0 || super::playback::pending(app) {
if app.session.actions.recording.is_some()
|| app.session.actions.playing > 0
|| super::playback::pending(app)
|| app.paused_playbacks.paused.values().any(|paused| paused.menu_editor.is_some())
{
return Err(tl!("Stop recording or playback before changing the Actions library.").into());
}
Ok(())
+10 -4
View File
@@ -106,10 +106,16 @@ fn insert_menu_item_chooser_cancels_or_records_descriptor_free_filter_event() {
h.state_mut().session.actions.list[0].steps.push(("select.all".into(), json!({})));
let paused = h.state_mut().run("actions.play", json!({"action":"A"})).unwrap();
let dialog = paused["paused"]["dialog"].as_u64().unwrap();
h.state_mut().ui.dialog_mut(dialog).unwrap().fields.insert("radius".into(), json!(2));
dialogs::confirm(h.state_mut(), dialog).unwrap();
assert_eq!(photocraft_compose::flatten(&h.state().session.active().unwrap().doc).into_px(), expected);
assert!(h.state().session.active().unwrap().doc.selection.is_some(), "confirmation resumes the following step");
let app = h.state_mut();
let actions = app.session.actions.list.clone();
assert!(app.run("actions.clearAll", json!({"confirm":true})).is_err());
assert_eq!(app.session.actions.list, actions);
app.ui.dialog_mut(dialog).unwrap().fields.insert("radius".into(), json!(2));
dialogs::confirm(app, dialog).unwrap();
assert_eq!(photocraft_compose::flatten(&app.session.active().unwrap().doc).into_px(), expected);
assert!(app.session.active().unwrap().doc.selection.is_some(), "confirmation resumes the following step");
app.run("actions.clearAll", json!({"confirm":true})).unwrap();
assert!(app.session.actions.list.is_empty());
}
/// The control protocol distinguishes direct playback from a menu click, even with a step gate.