mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-24 02:46:33 +11:00
Panic if the user attempts to run an event loop on a non-main thread on macOS
This commit is contained in:
parent
ea19409960
commit
fd0ddee63c
1 changed files with 8 additions and 0 deletions
|
@ -47,6 +47,10 @@ impl EventsLoop {
|
||||||
where F: FnMut(Event),
|
where F: FnMut(Event),
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
|
if !msg_send![cocoa::base::class("NSThread"), isMainThread] {
|
||||||
|
panic!("Events can only be polled from the main thread on macOS");
|
||||||
|
}
|
||||||
|
|
||||||
self.store_callback(callback);
|
self.store_callback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +98,10 @@ impl EventsLoop {
|
||||||
self.interrupted.store(false, std::sync::atomic::Ordering::Relaxed);
|
self.interrupted.store(false, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
if !msg_send![cocoa::base::class("NSThread"), isMainThread] {
|
||||||
|
panic!("Events can only be polled from the main thread on macOS");
|
||||||
|
}
|
||||||
|
|
||||||
self.store_callback(callback);
|
self.store_callback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue