From b9e32a4ac022b9e7ee3eee58b39dcd5acaf371ce Mon Sep 17 00:00:00 2001 From: Marko Toplak Date: Thu, 12 Oct 2023 14:04:28 +0200 Subject: [PATCH] spectra: do not send selection_changed on the same selection --- orangecontrib/spectroscopy/widgets/owspectra.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/orangecontrib/spectroscopy/widgets/owspectra.py b/orangecontrib/spectroscopy/widgets/owspectra.py index deaa05d43..1db4a7a5a 100644 --- a/orangecontrib/spectroscopy/widgets/owspectra.py +++ b/orangecontrib/spectroscopy/widgets/owspectra.py @@ -1322,6 +1322,8 @@ def current_selection(): old_sel_ci = current_selection() + changed = False + if add_to_group: # both keys - need to test it before add_group selnum = np.max(self.selection_group) elif add_group: @@ -1331,15 +1333,20 @@ def current_selection(): else: # remove the current selection redraw_curve_indices.update(old_sel_ci) - self.selection_group *= 0 # remove + if np.any(self.selection_group): + self.selection_group *= 0 # remove + changed = True selnum = 1 # add new if data_indices is not None: self.selection_group[data_indices] = selnum redraw_curve_indices.update( icurve for idata, icurve in invd.items() if idata in data_indices_set) + changed = True fixes = self.make_selection_valid() + if fixes: + changed = True redraw_curve_indices.update( icurve for idata, icurve in invd.items() if idata in fixes) @@ -1351,7 +1358,8 @@ def current_selection(): redraw_curve_indices.update(old_sel_ci) self.set_curve_pens(redraw_curve_indices) - self.selection_changed_confirm() + if changed: + self.selection_changed_confirm() def make_selection_valid(self): """ Make the selection valid and return the changed positions. """