Forráskód Böngészése

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

david 4 éve
szülő
commit
3389bd8180
3 módosított fájl, 19 hozzáadás és 3 törlés
  1. 5 0
      .changes/tauri-updater-linux.md
  2. 1 0
      core/tauri/Cargo.toml
  3. 13 3
      core/tauri/src/app.rs

+ 5 - 0
.changes/tauri-updater-linux.md

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

+ 1 - 0
core/tauri/Cargo.toml

@@ -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"

+ 13 - 3
core/tauri/src/app.rs

@@ -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)
   }