From c4c31c36502c43a4e660902cec8c550282ba610f Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Mon, 28 Nov 2016 15:41:56 +0100 Subject: [PATCH] Fix `cleanup` when the running qt application is not a QApplication --- pyqtgraph/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 301f9f1e..bc5081f7 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -303,7 +303,10 @@ def cleanup(): ## ALL QGraphicsItems must have a scene before they are deleted. ## This is potentially very expensive, but preferred over crashing. ## Note: this appears to be fixed in PySide as of 2012.12, but it should be left in for a while longer.. - if QtGui.QApplication.instance() is None: + app = QtGui.QApplication.instance() + if app is None or not isinstance(app, QtGui.QApplication): + # app was never constructed is already deleted or is an + # QCoreApplication/QGuiApplication and not a full QApplication return import gc s = QtGui.QGraphicsScene()