Skip to content

Commit 3389bd8

Browse files
authored
fix(linux): use glib main context for the updater on linux (#2222)
1 parent f0a8db6 commit 3389bd8

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

.changes/tauri-updater-linux.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Use glib context for linux updater to prevent GTK panic.

core/tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ minisign-verify = { version = "0.1", optional = true }
7171

7272
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
7373
gtk = { version = "0.9", features = [ "v3_16" ] }
74+
glib = "0.10"
7475

7576
[build-dependencies]
7677
cfg_aliases = "0.1.1"

core/tauri/src/app.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,19 @@ impl<R: Runtime> App<R> {
369369
fn run_updater_dialog(&self, window: Window<R>) {
370370
let updater_config = self.manager.config().tauri.updater.clone();
371371
let package_info = self.manager.package_info().clone();
372+
373+
#[cfg(not(target_os = "linux"))]
372374
crate::async_runtime::spawn(async move {
373375
updater::check_update_with_dialog(updater_config, package_info, window).await
374376
});
377+
378+
#[cfg(target_os = "linux")]
379+
{
380+
let context = glib::MainContext::default();
381+
context.spawn_with_priority(glib::PRIORITY_HIGH, async move {
382+
updater::check_update_with_dialog(updater_config, package_info, window).await
383+
});
384+
}
375385
}
376386

377387
/// Listen updater events when dialog are disabled.
@@ -807,9 +817,6 @@ impl<R: Runtime> Builder<R> {
807817
}
808818
}
809819

810-
#[cfg(feature = "updater")]
811-
app.run_updater(main_window);
812-
813820
(self.setup)(&mut app).map_err(|e| crate::Error::Setup(e))?;
814821

815822
#[cfg(feature = "system-tray")]
@@ -882,6 +889,9 @@ impl<R: Runtime> Builder<R> {
882889
}
883890
}
884891

892+
#[cfg(feature = "updater")]
893+
app.run_updater(main_window);
894+
885895
Ok(app)
886896
}
887897

0 commit comments

Comments
 (0)