Skip to content

avoid crash when window is null in become_first_responder #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading