From fe41dab89442ea755bd1ee93ff19f3893578e3e0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 9 Sep 2020 09:49:03 +0200 Subject: [PATCH] Gui: [skip ci] fix bugs in spin box classes: + use correct format string when assigning value to an expression + do not round value when setting value of a DoubleSpinBox --- src/Gui/SpinBox.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index b5a5d2731d..74d45b7c77 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -409,6 +409,7 @@ void UIntSpinBox::keyPressEvent(QKeyEvent *event) QAbstractSpinBox::keyPressEvent(event); } +// ---------------------------------------------------------------------------- IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) { @@ -437,7 +438,7 @@ IntSpinBox::~IntSpinBox() { bool IntSpinBox::apply(const std::string& propName) { if (!ExpressionBinding::apply(propName)) { - Gui::Command::doCommand(Gui::Command::Doc, "%s = %u", propName.c_str(), value()); + Gui::Command::doCommand(Gui::Command::Doc, "%s = %d", propName.c_str(), value()); return true; } else @@ -586,6 +587,7 @@ void IntSpinBox::keyPressEvent(QKeyEvent *event) QAbstractSpinBox::keyPressEvent(event); } +// ---------------------------------------------------------------------------- DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) { @@ -614,11 +616,11 @@ DoubleSpinBox::~DoubleSpinBox() { bool DoubleSpinBox::apply(const std::string& propName) { if (!ExpressionBinding::apply(propName)) { - Gui::Command::doCommand(Gui::Command::Doc, "%s = %u", propName.c_str(), value()); + Gui::Command::doCommand(Gui::Command::Doc, "%s = %f", propName.c_str(), value()); return true; } - else - return false; + + return false; } void DoubleSpinBox::bind(const ObjectIdentifier& _path) { @@ -654,7 +656,7 @@ void DoubleSpinBox::onChange() { NumberExpression * value = freecad_dynamic_cast(result.get()); if (value) { - setValue(boost::math::round(value->getValue())); + setValue(value->getValue()); setReadOnly(true); iconLabel->setPixmap(getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)));