Skip to content

Commit

Permalink
fix: signal race condition when editing filters in AnalysisView (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 18, 2025
1 parent 8444aae commit 650188b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2.21.2
- fix: signal race condition when editing filters in AnalysisView (#148)
- enh: when batch-loading datasets, allow individual files to fail
- enh: auto-select logs in AnalysisView
- enh: improve table graph selection (remember graph, clear if unavailable)
Expand Down
19 changes: 13 additions & 6 deletions shapeout2/gui/analysis/ana_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,22 @@ def set_pipeline(self, pipeline):
def show_filter(self, filt_id):
self.update_content(filt_index=self.filter_ids.index(filt_id))

def update_content(self, event=None, filt_index=None):
def update_content(self, filt_index=None, **kwargs):
if self.filter_ids:
# remember the previous filter index and make sure it is sane
prev_index = self.comboBox_filters.currentIndex()
if prev_index is None or prev_index < 0:
prev_index = len(self.filter_ids) - 1

self.setEnabled(True)
self.update_polygon_filters(update_state=False)
# update combobox
self.comboBox_filters.blockSignals(True)
if filt_index is None:
filt_index = self.comboBox_filters.currentIndex()
if filt_index > len(self.filter_ids) - 1 or filt_index < 0:
filt_index = len(self.filter_ids) - 1
if filt_index is None or filt_index < 0:
# fallback to previous filter index
filt_index = prev_index
filt_index = min(filt_index, len(self.filter_ids) - 1)

self.comboBox_filters.clear()
self.comboBox_filters.addItems(self.filter_names)
self.comboBox_filters.setCurrentIndex(filt_index)
Expand Down Expand Up @@ -330,5 +336,6 @@ def write_filter(self):
"""Update the shapeout2.pipeline.Filter instance"""
# get current index
filter_state = self.read_pipeline_state()
# this signal will update the main pipeline which will trigger
# a call to `set_pipeline` and `update_content`.
self.filter_changed.emit(filter_state)
self.update_content() # update filter selection combobox

This comment has been minimized.

Copy link
@paulmueller

paulmueller Jan 18, 2025

Author Member

Emitting the filter_changed signal above could potentially cause a race condition with this update_content, since update_event is called downstream of the filter_changed signal. This could explain #148.

0 comments on commit 650188b

Please sign in to comment.