Skip to content

fix resizeEvent in FigureCanvasQTAgg - #17612

Closed
eyllanesc wants to merge 1 commit into
matplotlib:masterfrom
eyllanesc:fix_resizeEvent_FigureCanvasQTAgg
Closed

eyllanesc wants to merge 1 commit into
matplotlib:masterfrom
eyllanesc:fix_resizeEvent_FigureCanvasQTAgg

Conversation

@eyllanesc

@eyllanesc eyllanesc commented Jun 10, 2020 •

Copy link
Copy Markdown

When FigureCanvasQTAgg is used with a QSplitter the resizeEvent() method receives an event where the width or height can be 0 generating the winch or hinch to be 0 and this throws an exception:

Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\matplotlib\backends\backend_qt5.py", line 397, in resizeEvent
    self.figure.set_size_inches(winch, hinch, forward=False)
  File "C:\Python36\lib\site-packages\matplotlib\figure.py", line 902, in set_size_inches
    raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [0.   6.12]

A possible solution to the problem is to verify that the dimensions are positive, and that is what I have implemented in this PR.

Relative #17608

@tacaswell

Copy link
Copy Markdown
Member

We also have #17610 which adjust the check in question. I think that is slightly better as it make sure the widget and the figure agree on how big they are?

@tacaswell

Copy link
Copy Markdown
Member

@eyllanesc Now that #17610 is merged do we still need this change? Can you confirm that the current master branch works for you?

@QuLogic

QuLogic commented Jun 12, 2020

Copy link
Copy Markdown
Member

The example in #17608 no longer segfaults, so I think we don't need this anymore.

Thanks for the PR, @eyllanesc; hope to see you again if you find something else to improve.

@QuLogic QuLogic closed this Jun 12, 2020
@QuLogic QuLogic modified the milestones: v3.3.0, unassigned Jul 9, 2020
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.

3 participants