Work around PySide setOverrideCursor bug in BusyCursor

This commit is contained in:
Kenneth Lyons 2019-06-24 15:39:12 -07:00
parent 7506ee3d3f
commit 8067ee25d5

View File

@ -1,4 +1,4 @@
from ..Qt import QtGui, QtCore from ..Qt import QtGui, QtCore, QT_LIB
__all__ = ['BusyCursor'] __all__ = ['BusyCursor']
@ -17,7 +17,12 @@ class BusyCursor(object):
app = QtCore.QCoreApplication.instance() app = QtCore.QCoreApplication.instance()
isGuiThread = (app is not None) and (QtCore.QThread.currentThread() == app.thread()) isGuiThread = (app is not None) and (QtCore.QThread.currentThread() == app.thread())
if isGuiThread and QtGui.QApplication.instance() is not None: if isGuiThread and QtGui.QApplication.instance() is not None:
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) if QT_LIB == 'PySide':
# pass CursorShape rather than QCursor for PySide
# see https://bugreports.qt.io/browse/PYSIDE-243
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
else:
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
BusyCursor.active.append(self) BusyCursor.active.append(self)
self._active = True self._active = True
else: else:
@ -27,4 +32,3 @@ class BusyCursor(object):
if self._active: if self._active:
BusyCursor.active.pop(-1) BusyCursor.active.pop(-1)
QtGui.QApplication.restoreOverrideCursor() QtGui.QApplication.restoreOverrideCursor()