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