fix(core): clear State map on exit

This commit is contained in:
FabianLars
2025-11-05 15:43:23 +01:00
parent dd70d213cd
commit 69e00db0e6
2 changed files with 8 additions and 0 deletions

View File

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

View File

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