Fix: Reset ParentItem to None on removing from PlotItem/ViewBox (#1031)
This commit is contained in:
parent
e3884ebd20
commit
8309b53014
@ -563,8 +563,8 @@ class PlotItem(GraphicsWidget):
|
||||
if item in self.dataItems:
|
||||
self.dataItems.remove(item)
|
||||
|
||||
if item.scene() is not None:
|
||||
self.vb.removeItem(item)
|
||||
self.vb.removeItem(item)
|
||||
|
||||
if item in self.curves:
|
||||
self.curves.remove(item)
|
||||
self.updateDecimation()
|
||||
|
@ -399,10 +399,12 @@ class ViewBox(GraphicsWidget):
|
||||
"""
|
||||
if item.zValue() < self.zValue():
|
||||
item.setZValue(self.zValue()+1)
|
||||
|
||||
scene = self.scene()
|
||||
if scene is not None and scene is not item.scene():
|
||||
scene.addItem(item) ## Necessary due to Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616
|
||||
item.setParentItem(self.childGroup)
|
||||
|
||||
if not ignoreBounds:
|
||||
self.addedItems.append(item)
|
||||
self.updateAutoRange()
|
||||
@ -413,7 +415,12 @@ class ViewBox(GraphicsWidget):
|
||||
self.addedItems.remove(item)
|
||||
except:
|
||||
pass
|
||||
self.scene().removeItem(item)
|
||||
|
||||
scene = self.scene()
|
||||
if scene is not None:
|
||||
scene.removeItem(item)
|
||||
item.setParentItem(None)
|
||||
|
||||
self.updateAutoRange()
|
||||
|
||||
def clear(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user