Skip to content

Not handling cancel action on single fit with multi constraint#3808

Merged
krzywon merged 1 commit intomainfrom
fix-cancel-button-complex-constraints
Dec 9, 2025
Merged

Not handling cancel action on single fit with multi constraint#3808
krzywon merged 1 commit intomainfrom
fix-cancel-button-complex-constraints

Conversation

@bmaranville
Copy link
Copy Markdown
Contributor

Description

When a user presses "Fit" from on a model, when constraints have been added which tie this model to other models, a dialog box opens which notifies the user that if they continue, the constraint will be disabled so that the single fit can continue.

Currently, if you press "Cancel", the action is not cancelled, and the fit proceeds (and the constraint is disabled).

image

How Has This Been Tested?

Loaded a model, then selected "FitPage1", then clicked "Fit" - and then clicked "Cancel". Fit was cancelled, and constraint was not disabled. See attached project for an example of a multi-model constrained fit project.
6-1-2-constrained-fit.json

Review Checklist:

[if using the editor, use [x] in place of [ ] to check a box]

Documentation (check at least one)

  • There is nothing that needs documenting
  • Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)
    • Wheels installer (GH artifact) has been tested (installed and worked)

Licensing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

… to inspect which button was pushed instead of looking at retval
@bmaranville bmaranville mentioned this pull request Dec 8, 2025
8 tasks
@bmaranville
Copy link
Copy Markdown
Contributor Author

This could also be fixed by an even smaller edit - the return value is 3 when the cancel button is pressed, but it is being compared directly to the RejectRole, which seems to be an enum, and the logic could alternatively be fixed by this:

diff --git i/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py w/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
index 90fb03f3b..0e38734a8 100644
--- i/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
+++ w/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
@@ -1330,7 +1330,7 @@ class FittingWidget(QtWidgets.QWidget, Ui_FittingWidgetUI):
             button_cancel = QtWidgets.QPushButton("Cancel")
             msgbox.addButton(button_cancel, QtWidgets.QMessageBox.RejectRole)
             retval = msgbox.exec_()
-            if retval == QtWidgets.QMessageBox.RejectRole:
+            if retval == int(QtWidgets.QMessageBox.RejectRole):
                 # cancel fit
                 raise ValueError("Fitting cancelled")
             else:

@krzywon krzywon merged commit 0fd43bd into main Dec 9, 2025
40 checks passed
@krzywon krzywon deleted the fix-cancel-button-complex-constraints branch December 9, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants