Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions src/sas/qtgui/Perspectives/Fitting/PolydispersityWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,23 @@ def onPolyComboIndexChange(self, combo_string: str, row_index: int) -> None:
Modify polydisp. defaults on function choice
"""
# Get npts/nsigs for current selection
param = self.logic.model_parameters.form_volume_parameters[row_index]


# Determine the parameter base name from the polydisp model row label.
# This ensures we use the expanded shell name (e.g. 'thickness2') instead of a template like 'thickness[n]'.
try:
display_text = str(self.poly_model.item(row_index, 0).text())
param_base = display_text.replace('Distribution of ', '').strip()
except Exception:
# Fallback to the model_parameters list if something unexpected happens
try:
param = self.logic.model_parameters.form_volume_parameters[row_index]
param_base = param.name
except Exception:
logger.exception("Could not determine parameter name for polydisp row %r", row_index)
return


file_index = self.poly_model.index(row_index, self.lstPoly.itemDelegate().poly_function)
combo_box = self.lstPoly.indexWidget(file_index)
try:
Expand All @@ -286,13 +302,15 @@ def onPolyComboIndexChange(self, combo_string: str, row_index: int) -> None:

if combo_string == 'array':
try:
# assure the combo is at the right index
if combo_box is not None:
# assure the combo is at the right index
combo_box.blockSignals(True)
combo_box.setCurrentIndex(combo_box.findText(combo_string))
combo_box.blockSignals(False)
combo_box.blockSignals(True)
combo_box.setCurrentIndex(combo_box.findText(combo_string))
combo_box.blockSignals(False)
# Load the file
self.loadPolydispArray(row_index)
self.logic.kernel_module.set_dispersion(param.name, self.disp_model)
self.logic.kernel_module.set_dispersion(param_base, self.disp_model)
# uncheck the parameter
self.poly_model.item(row_index, 0).setCheckState(QtCore.Qt.Unchecked)
# disable the row
Expand All @@ -303,11 +321,12 @@ def onPolyComboIndexChange(self, combo_string: str, row_index: int) -> None:
self.poly_model.blockSignals(False)
return
except OSError:
combo_box.setCurrentIndex(self.orig_poly_index)
if combo_box is not None:
combo_box.setCurrentIndex(self.orig_poly_index)
# Pass for cancel/bad read
pass
else:
self.logic.kernel_module.set_dispersion(param.name, self.disp_model)
self.logic.kernel_module.set_dispersion(param_base, self.disp_model)

# Enable the row in case it was disabled by Array
self.poly_model.blockSignals(True)
Expand Down