VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Fix #5236: report a failed open -a, and keep Other Application while its path is cleared
ruchirguitar7c5670b79785
diff --git a/apps/vectorcraft/src/host_services.rs b/apps/vectorcraft/src/host_services.rsindex e23cea243..4004050ff 100644--- a/apps/vectorcraft/src/host_services.rs+++ b/apps/vectorcraft/src/host_services.rs@@ -357,6 +357,20 @@ fn open_file_with(app: &str, path: &str) -> Result<(), String> {c.arg(path);c};+ // macOS: `open` returns once Launch Services has the request, so waiting for it is brief and+ // reports an app it can't open (a folder named `.app` that isn't a bundle). Elsewhere the+ // editor itself runs: waiting would last until it closes.+ #[cfg(target_os = "macos")]+ {+ let out = c.output().map_err(|e| format!("can't open {path} in {}: {e}", app.display()))?;+ if out.status.success() {+ return Ok(());+ }+ let why = String::from_utf8_lossy(&out.stderr).trim().to_string();+ let why = if why.is_empty() { out.status.to_string() } else { why };+ Err(format!("can't open {path} in {}: {why}", app.display()))+ }+ #[cfg(not(target_os = "macos"))]c.spawn().map(|_| ()).map_err(|e| format!("can't open {path} in {}: {e}", app.display()))}diff --git a/crates/ui-egui/src/prefs_dialog.rs b/crates/ui-egui/src/prefs_dialog.rsindex 97be22146..ef18c3ec5 100644--- a/crates/ui-egui/src/prefs_dialog.rs+++ b/crates/ui-egui/src/prefs_dialog.rs@@ -427,6 +427,11 @@ fn edit_original_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str,// Other Application with no path typed yet is still System Default: the dialog remembers the// choice in a field of its own, which a new dialog and Reset Preferences start without.let mut other = !photocraft && (!cur.is_empty() || d.bool(CHOSE_OTHER_APP));+ // A path (saved or typed) also counts as the choice, so clearing it to type another keeps the+ // field.+ if other && !d.bool(CHOSE_OTHER_APP) {+ d.fields.insert(CHOSE_OTHER_APP.into(), json!(true));+ }let at = if photocraft {1} else if other {diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rsindex 143adc6e6..c2557aede 100644--- a/crates/ui-egui/src/prefs_dialog/tests.rs+++ b/crates/ui-egui/src/prefs_dialog/tests.rs@@ -434,6 +434,11 @@ fn edit_original_with_other_is_the_dialogs_own_choice() {a.ui.dialog = None;open(&mut a, Some("File Handling"));assert!(!shown(&mut a), "opened again: System Default");+ // A saved path counts as the choice: clearing it to type another keeps the field.+ a.ui.dialog.as_mut().unwrap().fields.insert("editOriginalApp".into(), json!("/Applications/Old.app"));+ assert!(shown(&mut a));+ a.ui.dialog.as_mut().unwrap().fields.insert("editOriginalApp".into(), json!(""));+ assert!(shown(&mut a), "the path cleared: still Other Application");// A path with spaces is kept as typed.let path = "/Applications/Visual Studio Code.app";a.ui.dialog.as_mut().unwrap().fields.insert("editOriginalApp".into(), json!(path));