Fix: Allow wrapped GraphicsLayoutWidget to be deleted before its wrapping Python object (#1022)

This commit is contained in:
2xB 2019-08-18 05:43:21 +02:00 committed by Ogi Moore
parent ff30a82298
commit 31f1ae586b

View File

@ -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