From 811b11c45228255dd9874cce143ce90dae84ff08 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sun, 4 Nov 2018 11:15:39 +0200 Subject: [PATCH] Fix .app bundle crash on macOS (cherry picked from commit cfce8de0b59e06c6e7fcf3579557525aa9062534) --- platform/osx/os_osx.mm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index a6450397989..6684ce51f25 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -330,13 +330,14 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto //_GodotInputWindowFocus(window, GL_TRUE); //_GodotPlatformSetCursorMode(window, window->cursorMode); - get_mouse_pos( - [OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream], - [OS_OSX::singleton->window_view backingScaleFactor]); - OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y)); + if (OS_OSX::singleton->get_main_loop()) { + get_mouse_pos( + [OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream], + [OS_OSX::singleton->window_view backingScaleFactor]); + OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y)); - if (OS_OSX::singleton->get_main_loop()) OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); + } } - (void)windowDidResignKey:(NSNotification *)notification {