Errors after merging.

--HG--
branch : DialogTools
This commit is contained in:
dismine 2014-05-26 17:33:44 +03:00
parent 6f009a8ee4
commit 6f7a30f3a7
2 changed files with 21 additions and 14 deletions

View File

@ -163,7 +163,6 @@ void DialogEndLine::SaveData()
formula.replace("\n"," ");
angle = ui->doubleSpinBoxAngle->value();
basePointId = getCurrentObjectId(ui->comboBoxBasePoint);
emit DialogClosed(QDialog::Accepted);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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();