From aa50296b9fe44da3e8131ed04c101ac4f32ad380 Mon Sep 17 00:00:00 2001 From: Ogi Date: Sun, 12 May 2019 17:30:40 -0700 Subject: [PATCH 1/3] gc.collect() causes segfault on pyside2, test will pass on pyqt5 bindings (did not test pyqt4 or pyside1) --- pyqtgraph/tests/test_qt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyqtgraph/tests/test_qt.py b/pyqtgraph/tests/test_qt.py index bfb98631..c86cd500 100644 --- a/pyqtgraph/tests/test_qt.py +++ b/pyqtgraph/tests/test_qt.py @@ -10,7 +10,6 @@ def test_isQObjectAlive(): o2 = pg.QtCore.QObject() o2.setParent(o1) del o1 - gc.collect() assert not pg.Qt.isQObjectAlive(o2) @pytest.mark.skipif(pg.Qt.QT_LIB == 'PySide', reason='pysideuic does not appear to be ' From d873ee6b264bcdc9897ce3206599877637dc78cf Mon Sep 17 00:00:00 2001 From: Ogi Date: Sun, 12 May 2019 17:31:12 -0700 Subject: [PATCH 2/3] fixes ImportError on importing pysideuic --- pyqtgraph/Qt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 88c27e27..696d65f5 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -100,10 +100,13 @@ def _loadUiType(uiFile): how to make PyQt4 and pyside look the same... http://stackoverflow.com/a/8717832 """ - import pysideuic + + if QT_LIB == "PYSIDE": + import pysideuic + else: + import pyside2uic as pysideuic import xml.etree.ElementTree as xml - #from io import StringIO - + parsed = xml.parse(uiFile) widget_class = parsed.find('widget').get('class') form_class = parsed.find('class').text From afb665ec992264f134607fb02cd81e6c311d67f2 Mon Sep 17 00:00:00 2001 From: Ogi Date: Sun, 12 May 2019 17:35:26 -0700 Subject: [PATCH 3/3] make use of shiboken2 directly for isValid method --- pyqtgraph/Qt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 696d65f5..0941c3c7 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -219,8 +219,12 @@ elif QT_LIB == PYSIDE2: except ImportError as err: QtTest = FailedImport(err) - isQObjectAlive = _isQObjectAlive - + try: + import shiboken2 + isQObjectAlive = shiboken2.isValid + except ImportError: + # use approximate version + isQObjectAlive = _isQObjectAlive import PySide2 VERSION_INFO = 'PySide2 ' + PySide2.__version__ + ' Qt ' + QtCore.__version__