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:
|
if item in self.dataItems:
|
||||||
self.dataItems.remove(item)
|
self.dataItems.remove(item)
|
||||||
|
|
||||||
if item.scene() is not None:
|
self.vb.removeItem(item)
|
||||||
self.vb.removeItem(item)
|
|
||||||
if item in self.curves:
|
if item in self.curves:
|
||||||
self.curves.remove(item)
|
self.curves.remove(item)
|
||||||
self.updateDecimation()
|
self.updateDecimation()
|
||||||
|
@ -399,10 +399,12 @@ class ViewBox(GraphicsWidget):
|
|||||||
"""
|
"""
|
||||||
if item.zValue() < self.zValue():
|
if item.zValue() < self.zValue():
|
||||||
item.setZValue(self.zValue()+1)
|
item.setZValue(self.zValue()+1)
|
||||||
|
|
||||||
scene = self.scene()
|
scene = self.scene()
|
||||||
if scene is not None and scene is not item.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
|
scene.addItem(item) ## Necessary due to Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616
|
||||||
item.setParentItem(self.childGroup)
|
item.setParentItem(self.childGroup)
|
||||||
|
|
||||||
if not ignoreBounds:
|
if not ignoreBounds:
|
||||||
self.addedItems.append(item)
|
self.addedItems.append(item)
|
||||||
self.updateAutoRange()
|
self.updateAutoRange()
|
||||||
@ -413,7 +415,12 @@ class ViewBox(GraphicsWidget):
|
|||||||
self.addedItems.remove(item)
|
self.addedItems.remove(item)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.scene().removeItem(item)
|
|
||||||
|
scene = self.scene()
|
||||||
|
if scene is not None:
|
||||||
|
scene.removeItem(item)
|
||||||
|
item.setParentItem(None)
|
||||||
|
|
||||||
self.updateAutoRange()
|
self.updateAutoRange()
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user