Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Fix macOS toolbar crash#30863
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix macOS toolbar crash#30863
Conversation
tacaswell left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Makes sense and I manually tested.
9e210e8 intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
greglucas commentedDec 15, 2025
Thanks@lilfer! If you're in macos backend bug squashing mode, there are several other similar reference counting issues hanging around I think if you have any ideas for those too:https://github.com/matplotlib/matplotlib/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22GUI%3A%20MacOSX%22 |
PR summary
Closes#28513
Fixes a segmentation fault in the _macosx backend that occurs when closing figures.
In the original implementation of
NavigationToolbar2, it relied on the window to hold the only strong reference tomessagebox. The toolbar sometimes living longer than the window—and thusmessagebox— resulted in the crash.I'm still not sure why this crash seems to only occur when closing a figure that was created in the event loop.
Fix:
NavigationToolbar2now also retainsmessagebox.I checked that
messageboxis deallocated after a figure is closed andgc.collect()runs.PR checklist