Catch std::bad_alloc exception.

--HG--
branch : develop
This commit is contained in:
dismine 2014-05-30 17:31:48 +03:00
parent db8cf12d49
commit 07f75f7212
2 changed files with 25 additions and 0 deletions

View file

@ -1888,6 +1888,25 @@ void MainWindow::LoadPattern(const QString &fileName)
Clear();
return;
}
catch (const std::bad_alloc &)
{
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error parsing file."));
msgBox.setInformativeText("std::bad_alloc");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
Clear();
return;
}
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged);
QString nameDraw = doc->GetNameActivDraw();

View file

@ -601,6 +601,9 @@ void VPattern::FullUpdateTree()
catch (const std::bad_alloc &)
{
delete scene;
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error parsing file."));
@ -609,6 +612,9 @@ void VPattern::FullUpdateTree()
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
emit ClearMainWindow();
return;
}