Skip to content

Commit

Permalink
fix(core): deadlock on window destroy (#8953)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Feb 23, 2024
1 parent 0606ab3 commit 6edc563
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-window-destroy-deadlock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:bug
---

Fixes a deadlock when the window is destroyed.
3 changes: 2 additions & 1 deletion core/tauri/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 4 additions & 0 deletions core/tauri/src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 6edc563

Please sign in to comment.