From b873cd9cf04abd9628d0cf3b83447956fac31e16 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 7 Sep 2015 12:30:32 +0300 Subject: [PATCH] Issue #910: Do not replace text in spin box if it is not changed --- src/ModuleBase/ModuleBase_Tools.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index a3cfca0a6..6ee563fc7 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -26,6 +26,9 @@ #include +const double tolerance = 1e-7; + + namespace ModuleBase_Tools { //****************************************************************** @@ -126,7 +129,7 @@ void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText) void setSpinValue(QDoubleSpinBox* theSpin, double theValue) { - if (theSpin->value() == theValue) + if (fabs(theSpin->value() - theValue) < tolerance) return; bool isBlocked = theSpin->blockSignals(true); theSpin->setValue(theValue); @@ -135,8 +138,8 @@ void setSpinValue(QDoubleSpinBox* theSpin, double theValue) void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue) { - //if (theSpin->value() == theValue) - // return; + if (fabs(theSpin->value() - theValue) < tolerance) + return; bool isBlocked = theSpin->blockSignals(true); theSpin->setValue(theValue); theSpin->blockSignals(isBlocked); -- 2.39.2