File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,13 @@ impl ThreadLocalStorage {
382
382
Self :: default ( )
383
383
}
384
384
385
+ /// Removes all resources.
386
+ pub fn clear ( & mut self ) {
387
+ // Drop resources normally to avoid the caveats described in
388
+ // https://doc.rust-lang.org/std/thread/struct.LocalKey.html
389
+ TLS . replace ( ThreadLocals :: new ( ) ) ;
390
+ }
391
+
385
392
/// Inserts a new resource with its default value.
386
393
///
387
394
/// If the resource already exists, nothing happens.
Original file line number Diff line number Diff line change @@ -1840,6 +1840,9 @@ mod runner {
1840
1840
tls. remove_resource :: < crate :: EventLoopWindowTarget < AppEvent > > ( ) ;
1841
1841
}
1842
1842
AppEvent :: Exit ( _) => {
1843
+ let tls = locals. as_mut ( ) . unwrap ( ) ;
1844
+ tls. clear ( ) ;
1845
+
1843
1846
* control_flow = ControlFlow :: Exit ;
1844
1847
}
1845
1848
AppEvent :: Error ( payload) => {
You can’t perform that action at this time.
0 commit comments