fix(linux): use glib main context for the updater on linux (#2222)

This commit is contained in:
david 2021-07-16 09:06:56 -04:00 committed by GitHub
parent f0a8db62e4
commit 3389bd8180
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch
---
Use glib context for linux updater to prevent GTK panic.

View File

@ -71,6 +71,7 @@ minisign-verify = { version = "0.1", optional = true }
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.9", features = [ "v3_16" ] }
glib = "0.10"
[build-dependencies]
cfg_aliases = "0.1.1"

View File

@ -369,9 +369,19 @@ impl<R: Runtime> App<R> {
fn run_updater_dialog(&self, window: Window<R>) {
let updater_config = self.manager.config().tauri.updater.clone();
let package_info = self.manager.package_info().clone();
#[cfg(not(target_os = "linux"))]
crate::async_runtime::spawn(async move {
updater::check_update_with_dialog(updater_config, package_info, window).await
});
#[cfg(target_os = "linux")]
{
let context = glib::MainContext::default();
context.spawn_with_priority(glib::PRIORITY_HIGH, async move {
updater::check_update_with_dialog(updater_config, package_info, window).await
});
}
}
/// Listen updater events when dialog are disabled.
@ -807,9 +817,6 @@ impl<R: Runtime> Builder<R> {
}
}
#[cfg(feature = "updater")]
app.run_updater(main_window);
(self.setup)(&mut app).map_err(|e| crate::Error::Setup(e))?;
#[cfg(feature = "system-tray")]
@ -882,6 +889,9 @@ impl<R: Runtime> Builder<R> {
}
}
#[cfg(feature = "updater")]
app.run_updater(main_window);
Ok(app)
}