Skip to content

Commit

Permalink
Merge pull request pyqtgraph#2263 from pijyoi/fix_busycursor
Browse files Browse the repository at this point in the history
add support for PySide6 6.3.0 QOverrideCursorGuard
  • Loading branch information
j9ac9k authored Apr 18, 2022
2 parents d956b08 + 3ed8d27 commit 714428a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyqtgraph/widgets/BusyCursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ def BusyCursor():
"""
app = QtCore.QCoreApplication.instance()
in_gui_thread = (app is not None) and (QtCore.QThread.currentThread() == app.thread())
need_cleanup = in_gui_thread
try:
if in_gui_thread:
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
guard = QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
if hasattr(QtGui, 'QOverrideCursorGuard') and isinstance(guard, QtGui.QOverrideCursorGuard):
# on PySide6 6.3.0, setOverrideCursor() returns a QOverrideCursorGuard context manager
# object that calls restoreOverrideCursor() for us
need_cleanup = False
yield
finally:
if in_gui_thread:
if need_cleanup:
QtWidgets.QApplication.restoreOverrideCursor()

0 comments on commit 714428a

Please sign in to comment.