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

This commit is contained in:
Lucas Fernandes Nogueira 2024-02-22 22:02:13 -03:00 committed by GitHub
parent 0606ab326b
commit 6edc563cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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