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 bb9ec1b

Browse filesBrowse files
committed
Merge pull request #4612 from pwuertz/fix_4604
FIX: Only use asynchronous redraw methods when handling GUI events in Qt5Agg Fix #4604
2 parents 8bd7cd6 + 7fb21c6 commit bb9ec1b
Copy full SHA for bb9ec1b

File tree

Expand file treeCollapse file tree

3 files changed

+6
-48
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+6
-48
lines changed

‎lib/matplotlib/backends/backend_qt4agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4agg.py
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,6 @@ def __init__(self, figure):
7373
self._drawRect = None
7474
self.blitbox = None
7575
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
76-
# it has been reported that Qt is semi-broken in a windows
77-
# environment. If `self.draw()` uses `update` to trigger a
78-
# system-level window repaint (as is explicitly advised in the
79-
# Qt documentation) the figure responds very slowly to mouse
80-
# input. The work around is to directly use `repaint`
81-
# (against the advice of the Qt documentation). The
82-
# difference between `update` and repaint is that `update`
83-
# schedules a `repaint` for the next time the system is idle,
84-
# where as `repaint` repaints the window immediately. The
85-
# risk is if `self.draw` gets called with in another `repaint`
86-
# method there will be an infinite recursion. Thus, we only
87-
# expose windows users to this risk.
88-
if sys.platform.startswith('win'):
89-
self._priv_update = self.repaint
90-
else:
91-
self._priv_update = self.update
9276

9377

9478
FigureCanvas = FigureCanvasQTAgg

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+3-14Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ def resizeEvent(self, event):
334334
hinch = h / dpival
335335
self.figure.set_size_inches(winch, hinch)
336336
FigureCanvasBase.resize_event(self)
337-
self.draw()
338-
self.update()
337+
self.draw_idle()
339338
QtWidgets.QWidget.resizeEvent(self, event)
340339

341340
def sizeHint(self):
@@ -417,17 +416,7 @@ def stop_event_loop(self):
417416
stop_event_loop.__doc__ = FigureCanvasBase.stop_event_loop_default.__doc__
418417

419418
def draw_idle(self):
420-
'update drawing area only if idle'
421-
d = self._idle
422-
self._idle = False
423-
424-
def idle_draw(*args):
425-
try:
426-
self.draw()
427-
finally:
428-
self._idle = True
429-
if d:
430-
QtCore.QTimer.singleShot(0, idle_draw)
419+
self.update()
431420

432421

433422
class MainWindow(QtWidgets.QMainWindow):
@@ -666,7 +655,7 @@ def zoom(self, *args):
666655
self._update_buttons_checked()
667656

668657
def dynamic_update(self):
669-
self.canvas.draw()
658+
self.canvas.draw_idle()
670659

671660
def set_message(self, s):
672661
self.message.emit(s)

‎lib/matplotlib/backends/backend_qt5agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5agg.py
+3-18Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ class FigureCanvasQTAggBase(object):
6363

6464
def drawRectangle(self, rect):
6565
self._drawRect = rect
66-
self.repaint()
66+
self.draw_idle()
6767

6868
def paintEvent(self, e):
6969
"""
7070
Copy the image from the Agg canvas to the qt.drawable.
7171
In Qt, all drawing should be done inside of here when a widget is
7272
shown onscreen.
7373
"""
74+
FigureCanvasAgg.draw(self)
7475

7576
# FigureCanvasQT.paintEvent(self, e)
7677
if DEBUG:
@@ -146,7 +147,7 @@ def draw(self):
146147
# causes problems with code that uses the result of the
147148
# draw() to update plot elements.
148149
FigureCanvasAgg.draw(self)
149-
self._priv_update()
150+
self.update()
150151

151152
def blit(self, bbox=None):
152153
"""
@@ -183,22 +184,6 @@ def __init__(self, figure):
183184
self._drawRect = None
184185
self.blitbox = None
185186
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
186-
# it has been reported that Qt is semi-broken in a windows
187-
# environment. If `self.draw()` uses `update` to trigger a
188-
# system-level window repaint (as is explicitly advised in the
189-
# Qt documentation) the figure responds very slowly to mouse
190-
# input. The work around is to directly use `repaint`
191-
# (against the advice of the Qt documentation). The
192-
# difference between `update` and repaint is that `update`
193-
# schedules a `repaint` for the next time the system is idle,
194-
# where as `repaint` repaints the window immediately. The
195-
# risk is if `self.draw` gets called with in another `repaint`
196-
# method there will be an infinite recursion. Thus, we only
197-
# expose windows users to this risk.
198-
if sys.platform.startswith('win'):
199-
self._priv_update = self.repaint
200-
else:
201-
self._priv_update = self.update
202187

203188

204189
FigureCanvas = FigureCanvasQTAgg

0 commit comments

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