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

cocoa: fix default icon search when standalone app is not an .app bundle #2852

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

rokm
Copy link
Contributor

@rokm rokm commented Sep 16, 2024

When trying to obtain the default application icon in macOS standalone application by querying CFBundleIconFile key, account for possibility that application is not built as an .app bundle. I.e., ensure that the returned string is not None before trying to construct pathlib.Path with it. If returned string is None, raise FileNotFoundError, which is handled by the calling layer.

This fixes TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType' error when application has no icon set and PyInstaller is used to build a POSIX executable (as opposed to an .app bundle).

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

When trying to obtain the default application icon in macOS standalone
application by querying `CFBundleIconFile` key, account for possibility
that application is not built as an .app bundle. I.e., ensure that the
returned string is not `None` before trying to construct `pathlib.Path`
with it. If returned string is `None`, raise `FileNotFoundError`, which
is handled by the calling layer.

This fixes `TypeError: argument should be a str or an os.PathLike object
where __fspath__ returns a str, not 'NoneType'` error when application
has no icon set and PyInstaller is used to build a POSIX executable
(as opposed to an .app bundle).
@rokm rokm force-pushed the fix-macos-default-icon-pyinstaller branch from fb923e8 to 75b1dd2 Compare September 16, 2024 13:54
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

I've added two small tweaks to release notes and an inline comment, but otherwise, this looks great - thanks for the fix!

cocoa/src/toga_cocoa/icons.py Show resolved Hide resolved
@freakboy3742 freakboy3742 merged commit 76ac0e1 into beeware:main Sep 17, 2024
38 checks passed
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.

2 participants