From 4830a0f80bd3b0ec58bc43cdbba0418f169952a9 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 6 Sep 2018 16:46:11 +0300 Subject: [PATCH] Issue #2626: Do not use non-initialized attribute for default value definition --- src/ModuleBase/ModuleBase_WidgetChoice.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index ea04160b5..c2d15b828 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -133,16 +133,23 @@ bool ModuleBase_WidgetChoice::restoreValueCustom() myChoiceCtrl->setChoiceList(aChoiceList); } } - if (aIntAttr->isInitialized()) + if (aIntAttr->isInitialized()) { myChoiceCtrl->setValue(aIntAttr->value()); + + myChoiceCtrl->blockSignals(isBlocked); + emit itemSelected(this, aIntAttr->value()); + myDefValue = aIntAttr->value(); + } else { bool aHasDefaultValue; int aDefaultVal = QString::fromStdString(getDefaultValue()).toInt(&aHasDefaultValue); - myChoiceCtrl->setValue(aHasDefaultValue ? aDefaultVal : 0); + int aVal = aHasDefaultValue ? aDefaultVal : 0; + myChoiceCtrl->setValue(aVal); + + myChoiceCtrl->blockSignals(isBlocked); + emit itemSelected(this, aVal); + myDefValue = aVal; } - myChoiceCtrl->blockSignals(isBlocked); - emit itemSelected(this, aIntAttr->value()); - myDefValue = aIntAttr->value(); myIsFirst = false; } return true; -- 2.39.2