diff --git a/src/silx/gui/plot/items/_roi_base.py b/src/silx/gui/plot/items/_roi_base.py index abd8cd99b2..43c53811c0 100644 --- a/src/silx/gui/plot/items/_roi_base.py +++ b/src/silx/gui/plot/items/_roi_base.py @@ -253,6 +253,8 @@ def __init__(self, parent=None): from ..tools import roi as roi_tools assert parent is None or isinstance(parent, roi_tools.RegionOfInterestManager) + # Must be done before _RegionOfInterestBase.__init__ + self._child = WeakList() _RegionOfInterestBase.__init__(self, parent) core.HighlightedMixIn.__init__(self) self.__text = None @@ -261,7 +263,6 @@ def __init__(self, parent=None): self._selectable = False self._focusProxy = None self._visible = True - self._child = WeakList() def _connectToPlot(self, plot): """Called after connection to a plot""" diff --git a/src/silx/gui/plot/tools/test/testRoiCore.py b/src/silx/gui/plot/tools/test/testRoiCore.py index 0b6b9f72b6..e7f6d8adaf 100644 --- a/src/silx/gui/plot/tools/test/testRoiCore.py +++ b/src/silx/gui/plot/tools/test/testRoiCore.py @@ -279,6 +279,14 @@ def testRemovedSelection(self): manager.removeRoi(item1) self.assertIs(manager.getCurrentRoi(), None) + def testInitROIWithParent(self): + manager = roi.RegionOfInterestManager(self.plot) + item = roi_items.PointROI(manager) + manager.addRoi(item) + self.qapp.processEvents() + manager.removeRoi(item) + self.qapp.processEvents() + def testMaxROI(self): """Test Max ROI""" origin1 = numpy.array([1.0, 10.0])