mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 04:40:04 -04:00
chore: move event loop recreation check into backends themselves
This commit is contained in:
@@ -6,7 +6,7 @@ use std::cell::Cell;
|
||||
use std::ffi::c_void;
|
||||
use std::os::windows::io::{AsRawHandle as _, FromRawHandle as _, OwnedHandle, RawHandle};
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
use std::sync::{Arc, LazyLock, Mutex, MutexGuard};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{fmt, mem, panic, ptr};
|
||||
@@ -195,6 +195,12 @@ impl EventLoop {
|
||||
pub fn new(
|
||||
attributes: &mut PlatformSpecificEventLoopAttributes,
|
||||
) -> Result<Self, EventLoopError> {
|
||||
static EVENT_LOOP_CREATED: AtomicBool = AtomicBool::new(false);
|
||||
if EVENT_LOOP_CREATED.swap(true, Ordering::Relaxed) {
|
||||
// For better cross-platformness.
|
||||
return Err(EventLoopError::RecreationAttempt);
|
||||
}
|
||||
|
||||
let thread_id = unsafe { GetCurrentThreadId() };
|
||||
|
||||
if !attributes.any_thread && thread_id != main_thread_id() {
|
||||
|
||||
Reference in New Issue
Block a user