Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Control channel: a failed app.open answers with the error and opens no alert

aionggea4740cbc8c9
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs
index 4c9562d2a..32450259c 100644
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@ -334,7 +334,7 @@ pub fn handle(app: &mut DesignApp, ctx: &egui::Context, req: &ControlRequest) ->
None => ok(json!({"width": img.width, "height": img.height, "pngBase64": designcraft_engine::cmd::base64_encode(&png)})),
}
}
- "app.open" => wrap(app.open_file("file.open", json!({"path": s("path")}))),
+ "app.open" => wrap(app.run("file.open", json!({"path": s("path")}))),
"app.save" => wrap(app.run("file.save", json!({"path": s("path")}))),
"app.export" => wrap(app.run("app.exportPng", json!({"path": s("path"), "page": p.get("page"), "scale": p.get("scale")}))),
"app.quit" => {
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 3126d53cc..43a08167f 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -977,5 +977,10 @@ mod tests {
assert!(app.run("file.open", json!({"path": "/nonexistent/x.designcraft"})).is_err());
assert!(app.ui.dialog.is_none(), "a scripted file.open doesn't raise an alert");
assert!(!app.ui.status.is_empty());
+ // The control channel's app.open answers with the error; no alert waits for a click.
+ let (req, _rx) = control::ControlRequest::new("app.open", json!({"path": "/nonexistent/x.designcraft"}));
+ let control::Outcome::Done(r) = control::handle(&mut app, &egui::Context::default(), &req) else { panic!("app.open answers") };
+ assert_eq!(r["ok"], json!(false), "{r}");
+ assert!(app.ui.dialog.is_none(), "a control-channel app.open doesn't raise an alert");
}
}