فهرست منبع

fix(core): deadlock on window destroy (#8953)

Lucas Fernandes Nogueira 1 سال پیش
والد
کامیت
6edc563cf9
4فایلهای تغییر یافته به همراه12 افزوده شده و 2 حذف شده
  1. 5 0
      .changes/fix-window-destroy-deadlock.md
  2. 2 1
      core/tauri/src/manager/mod.rs
  3. 4 0
      core/tauri/src/webview/mod.rs
  4. 1 1
      core/tauri/src/window/mod.rs

+ 5 - 0
.changes/fix-window-destroy-deadlock.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch:bug
+---
+
+Fixes a deadlock when the window is destroyed.

+ 2 - 1
core/tauri/src/manager/mod.rs

@@ -528,7 +528,8 @@ impl<R: Runtime> AppManager<R> {
   }
 
   pub(crate) fn on_window_close(&self, label: &str) {
-    if let Some(window) = self.window.windows_lock().remove(label) {
+    let window = self.window.windows_lock().remove(label);
+    if let Some(window) = window {
       for webview in window.webviews() {
         self.webview.webviews_lock().remove(webview.label());
       }

+ 4 - 0
core/tauri/src/webview/mod.rs

@@ -979,6 +979,10 @@ impl<R: Runtime> Webview<R> {
       .expect("could not locate webview parent window")
   }
 
+  pub(crate) fn window_label(&self) -> String {
+    self.window_label.lock().unwrap().clone()
+  }
+
   /// Executes a closure, providing it with the webview handle that is specific to the current platform.
   ///
   /// The closure is executed on the main thread.

+ 1 - 1
core/tauri/src/window/mod.rs

@@ -988,7 +988,7 @@ impl<R: Runtime> Window<R> {
       .webview
       .webviews_lock()
       .values()
-      .filter(|w| &w.window() == self)
+      .filter(|w| w.window_label() == self.label())
       .cloned()
       .collect()
   }