Update pydev_monkey_qt.py
PyCharm debugger can stop on QThread breakpoints with PySide2
@@ -35,7 +35,11 @@ def patch_qt(qt_support_mode):
patch_qt_on_import = None
try:
- import PySide # @UnresolvedImport @UnusedImport
+ import PySide2 # @UnresolvedImport @UnusedImport
+ qt_support_mode = 'pyside2'
+ except:
+ try:
+ import Pyside # @UnresolvedImport @UnusedImport
qt_support_mode = 'pyside'
except:
try:
@@ -48,8 +52,14 @@ def patch_qt(qt_support_mode):
except:
return
+ if qt_support_mode == 'pyside2':
+ try:
+ import PySide2.QtCore # @UnresolvedImport
+ _internal_patch_qt(PySide2.QtCore, qt_support_mode)
+ except:
+ return
- if qt_support_mode == 'pyside':
+ elif qt_support_mode == 'pyside':
try:
import PySide.QtCore # @UnresolvedImport
_internal_patch_qt(PySide.QtCore, qt_support_mode)
@@ -134,14 +144,14 @@ def _internal_patch_qt(QtCore, qt_support_mode='auto'):
QtCore.QObject.__init__(self)
self.thread = thread
self.original_started = original_started
- if qt_support_mode == 'pyside':
+ if qt_support_mode in ('pyside', 'pyside2'):
self._signal = original_started
else:
self._signal.connect(self._on_call)
self.original_started.connect(self._signal)
def connect(self, func, *args, **kwargs):
- if qt_support_mode == 'pyside':
+ if qt_support_mode in ('pyside', 'pyside2'):
return self._signal.connect(FuncWrapper(func), *args, **kwargs)
else:
return self._signal.connect(func, *args, **kwargs)
