Immediately exit in console mode.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-05 12:56:43 +03:00
parent bd2e1063e3
commit 7eff8e8b9c

View File

@ -289,8 +289,15 @@ bool MainWindow::LoadMeasurements(const QString &path)
{
qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Wrong units.")),
qUtf8Printable(tr("Application doesn't support standard table with inches.")));
if (VApplication::CheckGUI())
{
return false;
}
else
{
std::exit(V_EX_DATAERR);
}
}
m->SetDataSize();
m->SetDataHeight();
}
@ -306,8 +313,15 @@ bool MainWindow::LoadMeasurements(const QString &path)
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
delete m;
if (VApplication::CheckGUI())
{
return false;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
return true;
}
@ -2126,42 +2140,84 @@ void MainWindow::FullParseFile()
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
catch (const VExceptionConversionError &e)
{
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
catch (const VExceptionEmptyParameter &e)
{
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
catch (const VExceptionWrongId &e)
{
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
catch (VException &e)
{
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
catch (const std::bad_alloc &)
{
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
QString patternPiece = QString();
if (comboBoxDraws->currentIndex() != -1)
@ -2200,15 +2256,29 @@ void MainWindow::GlobalChangePP(const QString &patternPiece)
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Bad id.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
catch (const VExceptionEmptyParameter &e)
{
qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
SetEnabledGUI(false);
if (VApplication::CheckGUI())
{
return;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -3174,15 +3244,33 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
if (path.isEmpty())
{
Clear();
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
.arg(path)));
if (VApplication::CheckGUI())
{
return false;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
if (not LoadMeasurements(path))
{
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
.arg(path)));
Clear();
if (VApplication::CheckGUI())
{
return false;
}
else
{
std::exit(V_EX_NOINPUT);
}
}
else
{
watcher->addPath(path);
ui->actionShowM->setEnabled(true);
@ -3378,13 +3466,13 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
{
if (!qApp->CheckGUI())
{
vStdErr() << tr("The measurements file \"") << path << tr("\" could not be found.\n");
return QString();
return QString();// console mode doesn't support fixing path to a measurement file
}
QString text = tr("The measurements file <br/><br/> <b>%1</b> <br/><br/> %3").arg(path)
.arg(tr("could not be found. Do you want to update the file location"));
QMessageBox::StandardButton res = QMessageBox::question(this, "Loading measurements file", text,
else
{
const QString text = tr("The measurements file <br/><br/> <b>%1</b> <br/><br/> could not be found. Do you "
"want to update the file location").arg(path);
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Loading measurements file"), text,
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes);
if (res == QMessageBox::No)
@ -3491,6 +3579,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
}
}
}
}
return path;
}