Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8feb6d8

Browse filesBrowse files
committed
Avoid triggering full dpi change if it's unchanged.
This is essentially a revert of the `Text.get_window_extent` change to its dpi handling, but applies in _all_ cases. Depending on backend, we want to avoid this extraneous dpi change, because it can cause recursive event signals. For example, with GTK3, a resize will trigger its event loop, which eventually causes a re-draw. The re-draw would get to `Text.get_window_extent`, change the dpi (to the same value), and call `Figure.set_size_inches`, which would resize the window again. Depending on how much of the GTK event loop was processed, this may or may not trigger another draw, recursing again and again. Fixes #16934.
1 parent e702edd commit 8feb6d8
Copy full SHA for 8feb6d8

File tree

Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ def _set_dpi(self, dpi, forward=True):
442442
forward : bool
443443
Passed on to `~.Figure.set_size_inches`
444444
"""
445+
if dpi == self._dpi:
446+
# We don't want to cause undue events in backends.
447+
return
445448
self._dpi = dpi
446449
self.dpi_scale_trans.clear().scale(dpi)
447450
w, h = self.get_size_inches()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.