Fixed crash DialogUndo. After canceling fixing formula user will see again

DialogUndo and can try again. Button cancel make pattern broken, but left
posibility undo operation.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-03-03 17:47:31 +02:00
parent 8f0e5fbd78
commit de9534b6d5

View File

@ -248,10 +248,11 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
delete cal;
DialogUndo *dialogUndo = new DialogUndo(qApp->getMainWindow());
forever
{
if (dialogUndo->exec() == QDialog::Accepted)
{
UndoButton resultUndo = dialogUndo->Result();
delete dialogUndo;
const UndoButton resultUndo = dialogUndo->Result();
if (resultUndo == UndoButton::Fix)
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
@ -260,24 +261,23 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
if (dialog->exec() == QDialog::Accepted)
{
formula = dialog->GetFormula();
/* Need delete dialog here because parser in dialog don't allow use correct separator for parsing
* here. */
/* Need delete dialog here because parser in dialog don't allow use correct separator for
* parsing here. */
delete dialog;
Calculator *cal1 = new Calculator(data);
result = cal1->EvalFormula(formula);
delete cal1; /* Here can be memory leak, but dialog already check this formula and probability
* very low. */
break;
}
else
{
delete dialog;
throw;
}
}
else
{
QString what = QString("Undo wrong formula %1").arg(formula);
throw VExceptionUndo(what);
throw VExceptionUndo(QString("Undo wrong formula %1").arg(formula));
}
}
else
@ -286,6 +286,8 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
throw;
}
}
delete dialogUndo;
}
return result;
}