Commit ff24eecf authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch 'fix-flint-crash-on-rois' into 'master'

Workaround to fix segfault with a C++ deleted widget

Closes #2826

See merge request !3801
parents 7c888f6e bfa775bc
Pipeline #48807 passed with stages
in 107 minutes and 33 seconds
......@@ -583,6 +583,7 @@ class ShapesSelector(Selector):
plot = self.parent()
plot.removeDockWidget(self.__dock)
if self.__roiWidget is not None:
self.__roiWidget.selectionFinished.disconnect(self.__selectionFinished)
self.__roiWidget.clear()
self.__dock = None
self.__roiWidget = None
......@@ -598,9 +599,9 @@ class ShapesSelector(Selector):
self.selectionFinished.emit()
def __selectionFinished(self, selection: Sequence[RegionOfInterest]):
self.stop()
shapes = self.__roisFromGui(selection)
self.__selection = shapes
self.stop()
self.selectionFinished.emit()
......
......@@ -16,6 +16,7 @@ import re
from silx.gui import qt
from silx.gui import icons
from silx.gui import utils as qtutils
from silx.gui.plot.tools.roi import RegionOfInterestManager
from silx.gui.plot.tools.roi import RegionOfInterestTableWidget
from silx.gui.plot.items.roi import RectangleROI
......@@ -78,7 +79,7 @@ class RoiSelectionWidget(qt.QWidget):
self.roiManager.sigRoiAdded.connect(self.__roiAdded)
self.roiManager.sigRoiContextMenuRequested.connect(self.roiContextMenuRequested)
self.roiManager.sigCurrentRoiChanged.connect(self.__currentRoiChanged)
self.table = RegionOfInterestTableWidget()
self.table = RegionOfInterestTableWidget(self)
self.table.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
self.table.setSelectionMode(qt.QAbstractItemView.SingleSelection)
......@@ -283,7 +284,14 @@ class RoiSelectionWidget(qt.QWidget):
self.renameRoiRequested(roi)
def clear(self):
self.roiManager.clear()
roiManager = self.roiManager
if len(roiManager.getRois()) > 0:
# Weird: At this level self.table can be already deleted in C++ side
# The if rois > 0 is a work around
selectionModel = self.table.selectionModel()
with qtutils.blockSignals(selectionModel):
roiManager.clear()
try:
self.plot.setInteractiveMode(self.__previousMode)
except Exception:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment