diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index edb12a430..17b95e046 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -163,7 +163,6 @@ void DialogEndLine::SaveData() formula.replace("\n"," "); angle = ui->doubleSpinBoxAngle->value(); basePointId = getCurrentObjectId(ui->comboBoxBasePoint); - emit DialogClosed(QDialog::Accepted); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index f0cbb096c..fa247de2c 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -415,23 +415,31 @@ void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *l } else { - Calculator cal(data); - QString errorMsg; - // Replace line return with spaces for calc - QString formula = edit->toPlainText(); - formula.replace("\n"," "); - qreal result = cal.eval(formula, &errorMsg); - if (errorMsg.isEmpty() == false) + try + { + // Replace line return with spaces for calc + QString formula = edit->toPlainText(); + formula.replace("\n"," "); + formula = qApp->FormulaFromUser(formula); + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); + + label->setText(QString().setNum(result)); + flag = true; + palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); + emit ToolTip(""); + } + catch(qmu::QmuParserError &e) { label->setText(tr("Error")); flag = false; palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - } - else - { - label->setText(QString().setNum(result)); - flag = true; - palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); + emit ToolTip("Parser error: "+e.GetMsg()); + qDebug() << "\nMath parser error:\n" + << "--------------------------------------\n" + << "Message: " << e.GetMsg() << "\n" + << "Expression: " << e.GetExpr() << "\n" + << "--------------------------------------"; } } CheckState();