From 8630de29b973f54f107049ddd1cbceea96beba7c Mon Sep 17 00:00:00 2001 From: max Date: Sun, 6 Apr 2025 19:38:16 +0300 Subject: [PATCH 1/3] avoid crashing when window is null in become_first_responder --- src/macos/view.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/macos/view.rs b/src/macos/view.rs index bdf0c304..063ba24c 100644 --- a/src/macos/view.rs +++ b/src/macos/view.rs @@ -245,8 +245,12 @@ extern "C" fn become_first_responder(this: &Object, _sel: Sel) -> BOOL { let state = unsafe { WindowState::from_view(this) }; let is_key_window = unsafe { let window: id = msg_send![this, window]; - let is_key_window: BOOL = msg_send![window, isKeyWindow]; - is_key_window == YES + if window != nil { + let is_key_window: BOOL = msg_send![window, isKeyWindow]; + is_key_window == YES + } else { + false + } }; if is_key_window { state.trigger_deferrable_event(Event::Window(WindowEvent::Focused)); From 439fabea7edaa590d191000c28d76a74b86b540e Mon Sep 17 00:00:00 2001 From: max Date: Sat, 12 Apr 2025 11:18:18 +0300 Subject: [PATCH 2/3] temporarily allow "unexpected_cfgs" on macOS --- src/macos/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/macos/mod.rs b/src/macos/mod.rs index 02a0e36f..d5e7f591 100644 --- a/src/macos/mod.rs +++ b/src/macos/mod.rs @@ -1,3 +1,7 @@ +// This is required because the objc crate is causing a lot of warnings: https://github.com/SSheldon/rust-objc/issues/125 +// Eventually we should migrate to the objc2 crate and remove this. +#![allow(unexpected_cfgs)] + mod keyboard; mod view; mod window; From 422db5bf79115bfe9c480efc8eda61c758aa1e89 Mon Sep 17 00:00:00 2001 From: max Date: Sat, 12 Apr 2025 11:22:19 +0300 Subject: [PATCH 3/3] allow "unexpected_cfgs" in macOS OpenGL code --- src/gl/macos.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gl/macos.rs b/src/gl/macos.rs index 05f2aa20..436afb24 100644 --- a/src/gl/macos.rs +++ b/src/gl/macos.rs @@ -1,3 +1,7 @@ +// This is required because the objc crate is causing a lot of warnings: https://github.com/SSheldon/rust-objc/issues/125 +// Eventually we should migrate to the objc2 crate and remove this. +#![allow(unexpected_cfgs)] + use std::ffi::c_void; use std::str::FromStr;