From 31f1ae586bb788b2a927356c78d9bef96afc6f3e Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Sun, 18 Aug 2019 05:43:21 +0200 Subject: [PATCH] Fix: Allow wrapped GraphicsLayoutWidget to be deleted before its wrapping Python object (#1022) --- pyqtgraph/widgets/GraphicsView.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/widgets/GraphicsView.py b/pyqtgraph/widgets/GraphicsView.py index b3b921cd..3c553feb 100644 --- a/pyqtgraph/widgets/GraphicsView.py +++ b/pyqtgraph/widgets/GraphicsView.py @@ -399,9 +399,12 @@ class GraphicsView(QtGui.QGraphicsView): ev.ignore() ## not sure why, but for some reason this class likes to consume drag events def _del(self): - if self.parentWidget() is None and self.isVisible(): - msg = "Visible window deleted. To prevent this, store a reference to the window object." - warnings.warn(msg, RuntimeWarning, stacklevel=2) + try: + if self.parentWidget() is None and self.isVisible(): + msg = "Visible window deleted. To prevent this, store a reference to the window object." + warnings.warn(msg, RuntimeWarning, stacklevel=2) + except RuntimeError: + pass if sys.version_info[0] == 3 and sys.version_info[1] >= 4: GraphicsView.__del__ = GraphicsView._del