Skip to content
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

Fix NSApplication initialization to prevent some issues on macOS #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

martincapello
Copy link
Member

By calling [NSApplication run] and then [NSApplication stop] we are able to initialize the application instance and prevent issues in fullscreen mode (fix aseprite/aseprite#4795)

@aseprite-bot
Copy link
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

@martincapello martincapello force-pushed the fix-macos-fullscreen-issue branch from 92397f0 to 08bda1c Compare February 6, 2025 18:20
// need the application's initialization done inside run to prevent issues
// such as: https://github.com/aseprite/aseprite/issues/4795
[m_app run];

[m_appDelegate resetCliFiles];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put this line under the scope of the if clause as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case, we should test if dropping files to the app icon in the dock works. Probably it should be tested with the final Aseprite.app bundle, not only the bin/aseprite binary. I could give a try next week.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested with the binary with and without this fix, and it doesn't work either way. So it seems that we can only test this with the final bundle?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just kind of tested this by vandalizing a v1.3.12 bundle (replaced the release binary with a compiled one 😬) and it worked...not sure if it will work by creating the bundle, but seems like it.

@aseprite-bot
Copy link
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

By calling [NSApplication run] and then [NSApplication stop] we are able
to initialize the application instance and prevent issues in fullscreen
mode (fix aseprite/aseprite#4795)
@martincapello martincapello force-pushed the fix-macos-fullscreen-issue branch from 08bda1c to 5237850 Compare February 6, 2025 18:57
@aseprite-bot
Copy link
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

os/osx/app.mm Outdated
Comment on lines 56 to 61
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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add {} to contain the whole comment+statement:

Suggested change
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];
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];
}

// need the application's initialization done inside run to prevent issues
// such as: https://github.com/aseprite/aseprite/issues/4795
[m_app run];

[m_appDelegate resetCliFiles];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case, we should test if dropping files to the app icon in the dock works. Probably it should be tested with the final Aseprite.app bundle, not only the bin/aseprite binary. I could give a try next week.

@dacap dacap assigned martincapello and unassigned dacap Feb 7, 2025
@aseprite-bot
Copy link
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

@dacap
Copy link
Member

dacap commented Feb 7, 2025

Please @martincapello follow this rule https://github.com/aseprite/aseprite/blob/bbe656c856453b6a3d5cd617f8312417bcf11035/docs/CODING_STYLE.md?plain=1#L54-L59 even if those multiple lines are just comments.

@martincapello martincapello force-pushed the fix-macos-fullscreen-issue branch from a567b01 to 8099a17 Compare February 7, 2025 19:09
@martincapello
Copy link
Member Author

Please @martincapello follow this rule https://github.com/aseprite/aseprite/blob/bbe656c856453b6a3d5cd617f8312417bcf11035/docs/CODING_STYLE.md?plain=1#L54-L59 even if those multiple lines are just comments.

I saw your comment just after I pushed the last commit...

@aseprite-bot
Copy link
Collaborator

clang-tidy review says "All clean, LGTM! 👍"

@martincapello martincapello assigned dacap and unassigned martincapello Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project Tab Dragging Issue
3 participants