Merge pull request #653 from ales-erjavec/spot-item-cycle-leak

ScatterPlotItem: Fix a GC memory leak due to numpy issue 6581
This commit is contained in:
Luke Campagnola 2018-03-29 08:55:53 -07:00 committed by GitHub
commit 2ca9f53bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -857,11 +857,18 @@ class SpotItem(object):
def __init__(self, data, plot):
#GraphicsItem.__init__(self, register=False)
self._data = data
self._plot = plot
# SpotItems are kept in plot.data["items"] numpy object array which
# does not support cyclic garbage collection (numpy issue 6581).
# Keeping a strong ref to plot here would leak the cycle
self.__plot_ref = weakref.ref(plot)
#self.setParentItem(plot)
#self.setPos(QtCore.QPointF(data['x'], data['y']))
#self.updateItem()
@property
def _plot(self):
return self.__plot_ref()
def data(self):
"""Return the user data associated with this spot."""
return self._data['data']