Skip to content

Commit a567b01

Browse files
committed
[osx] Fix finishLaunching() call in CLI mode
1 parent 5237850 commit a567b01

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

os/osx/app.mm

+16-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ void setAppMode(AppMode appMode)
5252

5353
void finishLaunching()
5454
{
55-
// [m_app run] can only be called once.
56-
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
57-
// Note that the [m_app run] call doesn't block because we are calling
58-
// [NSApp stop] from [AppDelegateOSX applicationDidFinishLaunching]. We only
59-
// need the application's initialization done inside run to prevent issues
60-
// such as: https://github.com/aseprite/aseprite/issues/4795
61-
[m_app run];
55+
id runningApp = [NSRunningApplication currentApplication];
56+
// [m_app run] must be called once, if the app didn't finish launching yet.
57+
if (![runningApp isFinishedLaunching]) {
58+
// The run method must be called in GUI mode only, otherwise the
59+
// [AppDelegateOSX applicationDidFinishLaunching] doesn't get called
60+
// and [m_app run] ends up blocking the app.
61+
if ([runningApp activationPolicy] == NSApplicationActivationPolicyRegular)
62+
// Note that the [m_app run] call doesn't block because we are calling
63+
// [NSApp stop] from [AppDelegateOSX applicationDidFinishLaunching]. We only
64+
// need the application's initialization done inside run to prevent issues
65+
// such as: https://github.com/aseprite/aseprite/issues/4795
66+
[m_app run];
67+
else
68+
// The app is running in CLI mode, then we just call finishLaunching.
69+
[m_app finishLaunching];
70+
}
6271

6372
[m_appDelegate resetCliFiles];
6473
}

0 commit comments

Comments
 (0)