chore: move event loop recreation check into backends themselves

This commit is contained in:
Mads Marquart 2025-05-26 06:48:52 +02:00 committed by GitHub
parent 5f2c7350e9
commit 8ad016362a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 64 additions and 25 deletions

View file

@ -128,6 +128,12 @@ const GLOBAL_WINDOW: WindowId = WindowId::from_raw(0);
impl EventLoop {
pub fn new(attributes: &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 android_app = attributes.android_app.as_ref().expect(
"An `AndroidApp` as passed to android_main() is required to create an `EventLoop` on \
Android",