Skip to content

avoid calling wx.Bitmap() if width or height is zero #17261

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

Merged
merged 1 commit into from
Apr 30, 2020
Merged

avoid calling wx.Bitmap() if width or height is zero #17261

merged 1 commit into from
Apr 30, 2020

Conversation

newville
Copy link
Contributor

PR Summary

move call of wx.Bitmap() in FigureCanvasWxBase._onSize until after the height and width are determined to be > 1.

On MacOS for example, the current behavior can give an irritating (but mostly harmless) message of

Traceback (most recent call last):
  File "....lib/python3.7/site-packages/matplotlib/backends/backend_wx.py", line 698, in _onSize
    self.bitmap = wx.Bitmap(self._width, self._height)
wx._core.wxAssertionError: C++ assertion ""w > 0 && h > 0"" failed at /Users/robind/projects/bb2/dist-osx-py37/build/ext/wxWidgets/src/osx/core/bitmap.cpp(1008) in Create(): invalid bitmap size

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

looks reasonable.

Copy link
Contributor

@DietmarSchwertberger DietmarSchwertberger left a comment

Choose a reason for hiding this comment

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

Thanks. Just had the same problem...
wxPython 4.1 has many new assertions.

@tacaswell tacaswell added this to the v3.2.2 milestone Apr 29, 2020
@QuLogic QuLogic merged commit 31a034b into matplotlib:master Apr 30, 2020
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 30, 2020
QuLogic added a commit that referenced this pull request Apr 30, 2020
…261-on-v3.2.x

Backport PR #17261 on branch v3.2.x (avoid calling wx.Bitmap() if width or height is zero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants