mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 05:41:31 +11:00
Disallow cleanup for TLS in examples
Fixes issue on Wayland due to drop order, since TLS is being dropped after the event loop, while it shouldn't. In particular it fixes the crash in the window_run_return example.
This commit is contained in:
parent
059abb06fc
commit
e23186db8e
|
@ -14,6 +14,7 @@ pub(super) fn fill_window(window: &Window) {
|
|||
use softbuffer::{Context, Surface};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::num::NonZeroU32;
|
||||
use winit::window::WindowId;
|
||||
|
||||
|
@ -43,8 +44,12 @@ pub(super) fn fill_window(window: &Window) {
|
|||
}
|
||||
|
||||
thread_local! {
|
||||
/// A static, thread-local map of graphics contexts to open windows.
|
||||
static GC: RefCell<Option<GraphicsContext>> = RefCell::new(None);
|
||||
// NOTE: You should never do things like that, create context and drop it before
|
||||
// you drop the event loop. We do this for brevity to not blow up examples. We use
|
||||
// ManuallyDrop to prevent destructors from running.
|
||||
//
|
||||
// A static, thread-local map of graphics contexts to open windows.
|
||||
static GC: ManuallyDrop<RefCell<Option<GraphicsContext>>> = ManuallyDrop::new(RefCell::new(None));
|
||||
}
|
||||
|
||||
GC.with(|gc| {
|
||||
|
|
Loading…
Reference in a new issue