Skip to content

Commit dc6db47

Browse files
authored
Merge pull request #11567 from matplotlib/auto-backport-of-pr-11500-on-v2.2.x
Backport PR #11500 on branch v2.2.x
2 parents 243846f + 6802e88 commit dc6db47

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,6 @@ def destroy(self, *args):
680680
if self.window._destroying:
681681
return
682682
self.window._destroying = True
683-
self.window.destroyed.connect(self._widgetclosed)
684683
if self.toolbar:
685684
self.toolbar.destroy()
686685
self.window.close()

lib/matplotlib/backends/qt_compat.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
_sip_imported = False
103103

104104
# Now perform the imports.
105-
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYQT5):
105+
if QT_API in (QT_API_PYQT, QT_API_PYQTv2):
106106
try:
107107
import sip
108108
_sip_imported = True
@@ -135,18 +135,20 @@
135135
except:
136136
res = 'QVariant API v2 specification failed. Defaulting to v1.'
137137
_log.info(cond + res)
138-
if QT_API == QT_API_PYQT5:
139-
try:
140-
from PyQt5 import QtCore, QtGui, QtWidgets
141-
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
142-
except ImportError:
143-
if _fallback_to_qt4:
144-
# fell through, tried PyQt5, failed fall back to PyQt4
145-
QT_API = QT_API_PYQT
146-
QT_RC_MAJOR_VERSION = 4
147-
else:
148-
raise
149138

139+
if QT_API == QT_API_PYQT5:
140+
try:
141+
from PyQt5 import QtCore, QtGui, QtWidgets
142+
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
143+
except ImportError:
144+
if _fallback_to_qt4:
145+
# fell through, tried PyQt5, failed fall back to PyQt4
146+
QT_API = QT_API_PYQT
147+
QT_RC_MAJOR_VERSION = 4
148+
else:
149+
raise
150+
151+
if _sip_imported:
150152
# needs to be if so we can re-test the value of QT_API which may
151153
# have been changed in the above if block
152154
if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
@@ -168,23 +170,6 @@ def _getSaveFileName(*args, **kwargs):
168170
# call to getapi() can fail in older versions of sip
169171
def _getSaveFileName(*args, **kwargs):
170172
return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
171-
try:
172-
# Alias PyQt-specific functions for PySide compatibility.
173-
QtCore.Signal = QtCore.pyqtSignal
174-
try:
175-
QtCore.Slot = QtCore.pyqtSlot
176-
except AttributeError:
177-
# Not a perfect match but works in simple cases
178-
QtCore.Slot = QtCore.pyqtSignature
179-
180-
QtCore.Property = QtCore.pyqtProperty
181-
__version__ = QtCore.PYQT_VERSION_STR
182-
except NameError:
183-
# QtCore did not get imported, fall back to pyside
184-
if QT_RC_MAJOR_VERSION == 5:
185-
QT_API = QT_API_PYSIDE2
186-
else:
187-
QT_API = QT_API_PYSIDE
188173

189174

190175
if QT_API == QT_API_PYSIDE2:
@@ -211,6 +196,18 @@ def _getSaveFileName(*args, **kwargs):
211196
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
212197

213198

199+
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYQT5):
200+
# Alias PyQt-specific functions for PySide compatibility.
201+
QtCore.Signal = QtCore.pyqtSignal
202+
try:
203+
QtCore.Slot = QtCore.pyqtSlot
204+
except AttributeError:
205+
# Not a perfect match but works in simple cases
206+
QtCore.Slot = QtCore.pyqtSignature
207+
208+
QtCore.Property = QtCore.pyqtProperty
209+
__version__ = QtCore.PYQT_VERSION_STR
210+
214211
# Apply shim to Qt4 APIs to make them look like Qt5
215212
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYSIDE):
216213
'''Import all used QtGui objects into QtWidgets

0 commit comments

Comments
 (0)