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