Craft Anything: understand how any software works, and craft your own.
Rust
When the window can't open, the app says why instead of vanishing (#173)
BFlatd69d9e66a411
diff --git a/Cargo.lock b/Cargo.lockindex ac9c453e..fdcac38d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1131,6 +1131,7 @@ dependencies = ["craft-anything-ui-egui","eframe","log",+ "rfd","winresource",]diff --git a/apps/craft-anything/Cargo.toml b/apps/craft-anything/Cargo.tomlindex cc25e07d..5a9a25f3 100644--- a/apps/craft-anything/Cargo.toml+++ b/apps/craft-anything/Cargo.toml@@ -18,6 +18,9 @@ craft-anything-setup = { workspace = true }craft-anything-ui-egui = { workspace = true }eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "wayland", "x11", "persistence"] }log = { workspace = true }+# The one dialog the app shows itself: when its window can't open, so a start that shows nothing+# still says why (#166).+rfd = { workspace = true }[features]wasm-plugins = ["craft-anything-engine/wasm-plugins"]diff --git a/apps/craft-anything/src/main.rs b/apps/craft-anything/src/main.rsindex 04c9ef68..07f06e68 100644--- a/apps/craft-anything/src/main.rs+++ b/apps/craft-anything/src/main.rs@@ -66,7 +66,20 @@ fn main() -> eframe::Result {);match &run {Ok(()) => log::info!("closed"),- Err(e) => log::error!("the window couldn't start: {e}"),+ Err(e) => {+ log::error!("the window couldn't start: {e}");+ // Without a window the app would just vanish (#166): say why, and where the log is.+ let log = craft_anything_engine::settings::config_dir().join("desktop.log");+ let _ = rfd::MessageDialog::new()+ .set_level(rfd::MessageLevel::Error)+ .set_title("Craft Anything couldn't open its window")+ .set_description(format!(+ "{e}\n\nUpdating your graphics driver often fixes this. What happened is written to {}; please attach it if you report this.",+ log.display()+ ))+ .set_buttons(rfd::MessageButtons::Ok)+ .show();+ }}run}