Skip to content

Commit

Permalink
fix(multiwebview): remove webview from store on close (#8766)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 5, 2024
1 parent 48b1fd7 commit bd73ab0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/fix-webview-close.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:bug
---

When using the multiwebview mode, properly remove the webview from memory on `Webview::close`.
4 changes: 4 additions & 0 deletions core/tauri/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ impl<R: Runtime> AppManager<R> {
}
}

pub(crate) fn on_webview_close(&self, label: &str) {
self.webview.webviews_lock().remove(label);
}

pub fn windows(&self) -> HashMap<String, Window<R>> {
self.window.windows_lock().clone()
}
Expand Down
4 changes: 3 additions & 1 deletion core/tauri/src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,9 @@ impl<R: Runtime> Webview<R> {
if self.window.webview_window {
self.window.close()
} else {
self.webview.dispatcher.close().map_err(Into::into)
self.webview.dispatcher.close()?;
self.manager().on_webview_close(self.label());
Ok(())
}
}

Expand Down

0 comments on commit bd73ab0

Please sign in to comment.