mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-02 11:40:04 +08:00
fix(linux): return when the startup dialog cannot initialize GTK
This commit is contained in:
Generated
+1
@@ -1097,6 +1097,7 @@ dependencies = [
|
||||
"futures",
|
||||
"gethostname",
|
||||
"getrandom 0.4.3",
|
||||
"gtk",
|
||||
"http-body-util",
|
||||
"libc",
|
||||
"log",
|
||||
|
||||
@@ -57,7 +57,6 @@ tristr = { workspace = true }
|
||||
socket2 = { workspace = true }
|
||||
warp = { version = "0.4.4", features = ["server"] }
|
||||
open = "5.4.5"
|
||||
rfd = { version = "0.18.0", default-features = false, features = ["common-controls-v6"] }
|
||||
dirs = "7.0.0"
|
||||
dunce = "1.0.5"
|
||||
nanoid = "0.5"
|
||||
@@ -110,10 +109,14 @@ specta-typescript = "=0.0.13"
|
||||
libc = "0.2.191"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
gtk = "0.19"
|
||||
tauri = { workspace = true, features = ["linux-ksni"] }
|
||||
# Upstream has no session-end signal support on Linux; see crates/clash-verge-signal.
|
||||
clash-verge-signal = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_os = "linux"))'.dependencies]
|
||||
rfd = { version = "0.18.0", default-features = false, features = ["common-controls-v6"] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
tauri-plugin-wdio-webdriver = { version = "=2.0.0-next.0", optional = true }
|
||||
objc2 = "0.6.5"
|
||||
|
||||
@@ -30,6 +30,29 @@ pub(crate) fn report_error(error: &anyhow::Error) {
|
||||
}
|
||||
};
|
||||
|
||||
show_error_dialog(&message);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn show_error_dialog(message: &str) {
|
||||
use gtk::prelude::DialogExt as _;
|
||||
|
||||
// rfd's GTK3 MessageDialog waits indefinitely if its GTK worker fails to initialize.
|
||||
if gtk::init().is_err() {
|
||||
return;
|
||||
}
|
||||
|
||||
gtk::MessageDialog::builder()
|
||||
.message_type(gtk::MessageType::Error)
|
||||
.title("Clash Verge startup failed")
|
||||
.text(message)
|
||||
.buttons(gtk::ButtonsType::Ok)
|
||||
.build()
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn show_error_dialog(message: &str) {
|
||||
let _ = rfd::MessageDialog::new()
|
||||
.set_level(rfd::MessageLevel::Error)
|
||||
.set_title("Clash Verge startup failed")
|
||||
|
||||
Reference in New Issue
Block a user