-
Notifications
You must be signed in to change notification settings - Fork 51
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
Crash on status_bar.statusItemWithLength_
#575
Comments
status_bar.statusItemWithLength_(NSVariableStatusItemLength)
status_bar.statusItemWithLength_
This is most likely not a bug in PyObjC, but Cocoa being annoyingly crash prone when using GUI code when the app isn't initialised fully enough. from Cocoa import NSStatusBar, NSVariableStatusItemLength, NSApplication
NSApplication.sharedApplication()
status_bar = NSStatusBar.systemStatusBar()
status_item = status_bar.statusItemWithLength_(NSVariableStatusItemLength)
print(f"{status_item=}") This script works on my system (macOS 14.3.1, M1 laptop), but crashes with What the context in which the code is called? |
Hi @ronaldoussoren, thanks for sharing that snippet! I can confirm that your snippet works on my machine as well. It looks like my issue is related to how I imported the library (but the error doesn't occur on import). The following snippet breaks: from Foundation import *
from AppKit import *
NSApplication.sharedApplication()
status_bar = NSStatusBar.systemStatusBar()
status_item = status_bar.statusItemWithLength_(NSVariableStatusItemLength)
print(f"{status_item=}") FWIW it works on v8. Replacing |
Describe the bug
The following code:
crashes with the error:
The app terminates
terminated by signal SIGTRAP (Trace or breakpoint trap)
or for someillegal hardware instruction
.Platform information
To Reproduce
See description above.
Expected behavior
It should work, and not crash.
Additional context
The text was updated successfully, but these errors were encountered: