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