Skip to content

Commit

Permalink
[osx] Fix finishLaunching() call in CLI mode
Browse files Browse the repository at this point in the history
  • Loading branch information
martincapello committed Feb 7, 2025
1 parent 5237850 commit 8099a17
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions os/osx/app.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@ void setAppMode(AppMode appMode)

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

[m_appDelegate resetCliFiles];
}
Expand Down

0 comments on commit 8099a17

Please sign in to comment.