mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix(core): clear State map on exit
This commit is contained in:
@@ -1037,6 +1037,7 @@ macro_rules! shared_app_impl {
|
||||
for (_, webview) in self.manager.webviews() {
|
||||
webview.resources_table().clear();
|
||||
}
|
||||
unsafe { self.manager.state.clear() };
|
||||
}
|
||||
|
||||
/// Gets the invoke key that must be referenced when using [`crate::webview::InvokeRequest`].
|
||||
|
||||
@@ -149,6 +149,13 @@ impl StateManager {
|
||||
Some(*value)
|
||||
}
|
||||
|
||||
/// SAFETY: This will cause all references obtained through [Self::try_get] to dangle.
|
||||
/// This must only be called on app exit (in cleanup_before_exit).
|
||||
pub(crate) unsafe fn clear(&self) {
|
||||
let mut map = self.map.lock().unwrap();
|
||||
map.clear();
|
||||
}
|
||||
|
||||
/// Gets the state associated with the specified type.
|
||||
pub fn get<T: Send + Sync + 'static>(&self) -> State<'_, T> {
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user