Skip to content

Commit

Permalink
fix: signal race condition when editing plots in AnalysisView (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 18, 2025
1 parent 650188b commit 018ed10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2.21.2
- fix: signal race condition when editing filters in AnalysisView (#148)
- fix: signal race condition when editing plots in AnalysisView (#172)
- 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
21 changes: 12 additions & 9 deletions shapeout2/gui/analysis/ana_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,16 +578,21 @@ def show_plot(self, plot_id):
def set_pipeline(self, pipeline):
self._pipeline = pipeline

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

self.setEnabled(True)
# update combobox
self.comboBox_plots.blockSignals(True)
# this also updates the combobox
if plot_index is None:
plot_index = self.comboBox_plots.currentIndex()
if plot_index > len(self.plot_ids) - 1 or plot_index < 0:
plot_index = len(self.plot_ids) - 1
if plot_index is None or plot_index < 0:
plot_index = prev_index
plot_index = min(plot_index, len(self.plot_ids) - 1)

self.comboBox_plots.clear()
self.comboBox_plots.addItems(self.plot_names)
self.comboBox_plots.setCurrentIndex(plot_index)
Expand Down Expand Up @@ -626,9 +631,7 @@ def update_content(self, event=None, plot_index=None):
def write_plot(self):
"""Update the shapeout2.pipeline.Plot instance"""
# get current index
plot_index = self.comboBox_plots.currentIndex()

This comment has been minimized.

Copy link
@paulmueller

paulmueller Jan 18, 2025

Author Member

This is similar, but different to 650188b#r151502087

plot_changed is emitted at the end of this method, so I would not expect a race condition there. But we were editing a plot before we actually communicate that something changed with the new state, so there might have been unexpected behavior as well.

plot = Plot.get_plot(identifier=self.plot_ids[plot_index])
plot_state = self.read_pipeline_state()
plot.__setstate__(plot_state)
self.update_content() # update plot selection combobox
# this signal will update the main pipeline which will trigger
# a call to `set_pipeline` and `update_content`.
self.plot_changed.emit(plot_state)

0 comments on commit 018ed10

Please sign in to comment.