From db40eb1478fcf91f9108c4874a2bd412dfc67ed5 Mon Sep 17 00:00:00 2001 From: Billy Huddleston Date: Fri, 24 Oct 2025 15:08:57 -0400 Subject: [PATCH] CAM: Fix expression editor so that widgets refresh after closing src/Gui/QuantitySpinBox.cpp: - Call updateExpression() after setExpression() in QuantitySpinBox src/Gui/SpinBox.cpp: - Call updateExpression() after setExpression() in ExpressionSpinBox src/Gui/Widgets.cpp: - Call onChange() after setExpression() in ExpLineEdit src/Mod/CAM/Path/Base/Gui/Util.py: - Connect to showFormulaDialog signal and refresh CAM QuantitySpinBox Python wrapper when dialog closes --- src/Gui/Dialogs/DlgExpressionInput.cpp | 1 + src/Gui/QuantitySpinBox.cpp | 1 + src/Gui/SpinBox.cpp | 1 + src/Gui/Widgets.cpp | 1 + src/Mod/CAM/Path/Base/Gui/Util.py | 15 +++++++++++++++ 5 files changed, 19 insertions(+) diff --git a/src/Gui/Dialogs/DlgExpressionInput.cpp b/src/Gui/Dialogs/DlgExpressionInput.cpp index ab97462595..0db9b29f90 100644 --- a/src/Gui/Dialogs/DlgExpressionInput.cpp +++ b/src/Gui/Dialogs/DlgExpressionInput.cpp @@ -659,6 +659,7 @@ static App::Document* getPreselectedDocument() return doc; } + int DlgExpressionInput::getVarSetIndex(const App::Document* doc) const { auto paramExpressionEditor = App::GetApplication().GetParameterGroupByPath( diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 78c15746f9..4c7f03d77a 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -607,6 +607,7 @@ void QuantitySpinBox::openFormulaDialog() else if (box->discardedFormula()) setExpression(std::shared_ptr()); + updateExpression(); box->deleteLater(); Q_EMIT showFormulaDialog(false); }); diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 2523855d84..94df2f339f 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -196,6 +196,7 @@ void ExpressionSpinBox::openFormulaDialog() else if (box->discardedFormula()) setExpression(std::shared_ptr()); + updateExpression(); box->deleteLater(); }); box->show(); diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 2fe6a37d44..14c78e59dd 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -1621,6 +1621,7 @@ void ExpLineEdit::finishFormulaDialog() else if (box->discardedFormula()) setExpression(std::shared_ptr()); + onChange(); box->deleteLater(); if(autoClose) diff --git a/src/Mod/CAM/Path/Base/Gui/Util.py b/src/Mod/CAM/Path/Base/Gui/Util.py index 49c127e6b7..bf5cf055ac 100644 --- a/src/Mod/CAM/Path/Base/Gui/Util.py +++ b/src/Mod/CAM/Path/Base/Gui/Util.py @@ -131,6 +131,21 @@ class QuantitySpinBox(QtCore.QObject): self.widget.installEventFilter(self) # Connect local class method as slot self.widget.textChanged.connect(self.onWidgetValueChanged) + # Connect to showFormulaDialog signal to track dialog open/close + try: + self.widget.showFormulaDialog.connect(self.onFormulaDialogStateChanged) + except AttributeError: + # Widget may not have this signal + pass + + def onFormulaDialogStateChanged(self, isOpen): + """ + Slot called when the formula dialog is opened or closed. + When the dialog closes (isOpen=False), refresh the widget. + """ + if not isOpen: + # Dialog has closed, update the widget to reflect any changes + self.updateWidget() def eventFilter(self, obj, event): if event.type() == QtCore.QEvent.Type.FocusIn: