mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Fix crash on NetBSD
The `_lwp_self` function cannot be used to reliably determine the main thread, see https://github.com/alacritty/alacritty/issues/2631#issuecomment-676723289. It might always be equal to the PID, but it's certainly not always 1 when the thread is the main thread. However, Rust's built in `Thread::id` and `Thread::name` function will always return `ThreadId(1)` and `Some("main")`. Since converting the thread's ID to a number is not supported on stable Rust, checking that the thread is labeled `Some("main")` seems like the most reliable option. It should also be a good fallback in general.
This commit is contained in:
parent
9c72cc2a98
commit
89d4c06dec
|
@ -20,6 +20,7 @@
|
|||
- On macOS, add `NSWindow.hasShadow` support.
|
||||
- **Breaking:** On Web, `set_cursor_position` and `set_cursor_grab` will now always return an error.
|
||||
- **Breaking:** `PixelDelta` scroll events now return a `PhysicalPosition`.
|
||||
- On NetBSD, fixed crash due to incorrect detection of the main thread.
|
||||
|
||||
# 0.22.2 (2020-05-16)
|
||||
|
||||
|
|
|
@ -730,7 +730,5 @@ fn is_main_thread() -> bool {
|
|||
|
||||
#[cfg(target_os = "netbsd")]
|
||||
fn is_main_thread() -> bool {
|
||||
use libc::_lwp_self;
|
||||
|
||||
unsafe { _lwp_self() == 1 }
|
||||
std::thread::current().name() == Some("main")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue