From c6f09c5b5f49d52c0ed5a23d5734d7bc6a49de9a Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 28 May 2018 17:53:56 +0300 Subject: [PATCH] Parameters creation error processing --- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 1 - src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 6c5ce02bb..b718998df 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -273,7 +273,6 @@ void ModuleBase_ParamSpinBox::keyReleaseEvent(QKeyEvent* e) switch (e->key()) { case Qt::Key_Return: case Qt::Key_Enter: - case Qt::Key_Tab: { if (myCompleter->popup()->isVisible()) { myCompleter->popup()->hide(); diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index a2ad6b255..62aa739f3 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -162,6 +162,15 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom() if (aText.contains('=')) { if (!myParameter.get()) { myParameter = createParameter(aText); + if (!myParameter.get()) { + aReal->setExpressionError("Parameter cannot be created"); + aReal->setExpressionInvalid(true); + mySpinBox->setText(aReal->text().c_str()); + return false; + } else if (aReal->expressionInvalid()) { + aReal->setExpressionError(""); + aReal->setExpressionInvalid(false); + } } else { editParameter(aText); } @@ -192,9 +201,12 @@ bool ModuleBase_WidgetDoubleValue::restoreValueCustom() if (aText.endsWith('=')) { if (!myParameter.get()) { QString aName = aText.left(aText.indexOf('=')).trimmed(); - std::string aa = aName.toStdString(); myParameter = findParameter(aName); } + /// If myParameter is empty then it was not created because of an error + if (!myParameter.get()) + return false; + AttributeStringPtr aExprAttr = myParameter->string("expression"); aText += aExprAttr->value().c_str(); } @@ -232,6 +244,9 @@ FeaturePtr ModuleBase_WidgetDoubleValue::createParameter(const QString& theText) { FeaturePtr aParameter; QStringList aList = theText.split("="); + if (aList.count() != 2) { + return aParameter; + } QString aParamName = aList.at(0).trimmed(); if (isNameExist(aParamName)) { -- 2.39.2