From ba4d70e7a495fcb68ebd9b0ff13bcf61ed309579 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Tue, 7 Apr 2020 21:20:23 +0200 Subject: [PATCH] [Expression] Default to current 'constant' value when editing if no expression set yet ; fixes #4298 Move signals connecting before value initialization so it's not needed to call them manually Only spin boxes implemented (should be the major usage) --- src/Gui/DlgExpressionInput.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index 55426e0f80..40e3faa240 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -55,14 +55,20 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, // Setup UI ui->setupUi(this); - if (expression) { - ui->expression->setText(Base::Tools::fromStdString(expression->toString())); - textChanged(Base::Tools::fromStdString(expression->toString())); - } - // Connect signal(s) connect(ui->expression, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); connect(ui->discardBtn, SIGNAL(clicked()), this, SLOT(setDiscarded())); + + if (expression) { + ui->expression->setText(Base::Tools::fromStdString(expression->toString())); + } + else + { + QAbstractSpinBox *sb = dynamic_cast(parent); + if (sb) { + ui->expression->setText(sb->text()); + } + } // Set document object on line edit to create auto completer DocumentObject * docObj = path.getDocumentObject();