mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
nightly: a refused launch exits 2 on macOS instead of hanging
A refused launch profile printed its reason and then, on a macOS desktop session, opened rfd's message box before eframe's event loop existed. That alert needs the AppKit run loop this start never reaches, so the process sat in an invisible modal and had to be killed instead of exiting (seen on GridCraft's nightly Mac smoke, run 45749038918). The refusal now adds the box only where one renders without the app's event loop (Windows' MessageBox, GTK on X11/Wayland) and otherwise leaves the reason on standard error, so the caller's exit(2) is reached. The rule is a pure function with a unit test. PhotoCraft's clap `launch_args` already absorbs the Launcher's `--`, and its own Mac smoke passed: this is the dialog part only, applied preventively.
This commit is contained in:
1 parent
f0205ae336
commit
dde232da4a
1 file changed
+24
-1
@@ -420,12 +420,21 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit
|
||||
process_identity::initialize(build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1, os_window::id_for(os_window::LaunchIdentity::NightlyV1))
|
||||
}
|
||||
|
||||
/// Whether a refusal may also open a native message box. Standard error always carries the reason;
|
||||
/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert
|
||||
/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hangs in
|
||||
/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26). PhotoCraft's own Mac
|
||||
/// smoke passed, so this is preventive here.
|
||||
fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool {
|
||||
build_flavor::needs_native_error(flavor, desktop_session) && !macos
|
||||
}
|
||||
|
||||
fn report_launch_profile_error(error: &str) {
|
||||
eprintln!("PhotoCraft launch profile: {error}");
|
||||
let desktop_session = cfg!(windows)
|
||||
|| cfg!(target_os = "macos")
|
||||
|| (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty())));
|
||||
if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) {
|
||||
if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) {
|
||||
if let Err(error) = initialize_nightly_process_identity() {
|
||||
eprintln!("PhotoCraft launch profile: {error}");
|
||||
return;
|
||||
@@ -1403,3 +1412,17 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod refusal_dialog_tests {
|
||||
use super::refusal_dialog;
|
||||
use crate::build_flavor::BuildFlavor;
|
||||
|
||||
#[test]
|
||||
fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() {
|
||||
assert!(refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders");
|
||||
assert!(!refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang");
|
||||
assert!(!refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box");
|
||||
assert!(!refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user