fix(macos): gate Linux graphics CLI flags and crash handler with cfg

This commit is contained in:
Afonso Jorge Ramos committed 2026-04-03 03:19:52 +02:00
1 parent 3ac7073b9c
commit b1000cb9f0
2 files changed
+13 -4

No files matched your search

+1
View File
@@ -12,6 +12,7 @@ pub mod session_lifecycle;
pub mod tauri_adapter;
pub mod auto_theme;
#[cfg(target_os = "linux")]
pub mod autoconfig_graphics;
pub mod api;
+12 -4
View File
@@ -81,6 +81,10 @@ fn is_intel_gpu() -> bool {
}
fn main() {
// CLI flags for Linux graphics troubleshooting (X11/Wayland, GDK, GSK, DMA-BUF)
// These are no-ops on macOS/Windows where the graphics stack is managed by the OS.
#[cfg(target_os = "linux")]
{
// CLI flag: --autoconfig-graphics — detect environment and apply optimal settings
if std::env::args().any(|a| a == "--autoconfig-graphics") {
qbz_nix_lib::autoconfig_graphics::run();
@@ -159,6 +163,7 @@ fn main() {
}
return;
}
}
// Set the application name/class for Linux window managers
// This helps task managers and window switchers identify the app correctly
@@ -537,7 +542,7 @@ fn main() {
qbz_nix_lib::logging::log_startup(&format!("[QBZ] GPU rendering: {}", gpu_status));
}
// Catch GTK initialization panics and show a recovery message
// Catch panics during startup and show a recovery message
let result = std::panic::catch_unwind(|| qbz_nix_lib::run());
if let Err(panic_info) = result {
@@ -549,6 +554,9 @@ fn main() {
"Unknown panic".to_string()
};
// GTK initialization failures only happen on Linux (X11/Wayland graphics stack)
#[cfg(target_os = "linux")]
{
let is_gtk_failure = msg.contains("Failed to initialize gtk")
|| msg.contains("Failed to initialize GTK")
|| msg.contains("GDK_BACKEND");
@@ -571,11 +579,11 @@ fn main() {
eprintln!("╚══════════════════════════════════════════════════════════════╝");
eprintln!();
eprintln!("[QBZ] Error detail: {}", msg);
} else {
eprintln!("[QBZ] Fatal error: {}", msg);
eprintln!("[QBZ] If the app fails to start, try: qbz --reset-graphics");
std::process::exit(1);
}
}
eprintln!("[QBZ] Fatal error: {}", msg);
std::process::exit(1);
}
}