diff --git a/pyqtgraph/graphicsItems/tests/test_ImageItem.py b/pyqtgraph/graphicsItems/tests/test_ImageItem.py index ca197c6e..91926fe4 100644 --- a/pyqtgraph/graphicsItems/tests/test_ImageItem.py +++ b/pyqtgraph/graphicsItems/tests/test_ImageItem.py @@ -121,7 +121,7 @@ def test_ImageItem(transpose=False): assertImageApproved(w, 'imageitem/resolution_with_downsampling_y', 'Resolution test with downsampling across y axis.') assert img._lastDownsample == (1, 4) - view.hide() + w.hide() def test_ImageItem_axisorder(): # All image tests pass again using the opposite axis order diff --git a/pyqtgraph/graphicsItems/tests/test_ROI.py b/pyqtgraph/graphicsItems/tests/test_ROI.py index b22ad530..33a18217 100644 --- a/pyqtgraph/graphicsItems/tests/test_ROI.py +++ b/pyqtgraph/graphicsItems/tests/test_ROI.py @@ -153,6 +153,7 @@ def check_getArrayRegion(roi, name, testResize=True, transpose=False): # allow the roi to be re-used roi.scene().removeItem(roi) + win.hide() def test_PolyLineROI(): rois = [ @@ -234,5 +235,6 @@ def test_PolyLineROI(): r.setState(initState) assertImageApproved(plt, 'roi/polylineroi/'+name+'_setstate', 'Reset ROI to initial state.') assert len(r.getState()['points']) == 3 - - \ No newline at end of file + + plt.hide() + diff --git a/pyqtgraph/widgets/GraphicsView.py b/pyqtgraph/widgets/GraphicsView.py index 4aa2e90a..b3b921cd 100644 --- a/pyqtgraph/widgets/GraphicsView.py +++ b/pyqtgraph/widgets/GraphicsView.py @@ -15,6 +15,7 @@ except ImportError: from ..Point import Point import sys, os +import warnings from .FileDialog import FileDialog from ..GraphicsScene import GraphicsScene import numpy as np @@ -396,5 +397,11 @@ class GraphicsView(QtGui.QGraphicsView): def dragEnterEvent(self, ev): 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) + +if sys.version_info[0] == 3 and sys.version_info[1] >= 4: + GraphicsView.__del__ = GraphicsView._del