From: vsv Date: Mon, 28 May 2018 14:53:56 +0000 (+0300) Subject: Parameters creation error processing X-Git-Tag: EDF_2018-1~33^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6f09c5b5f49d52c0ed5a23d5734d7bc6a49de9a;p=modules%2Fshaper.git Parameters creation error processing --- 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)) {