Fixed crash on Windows.
--HG-- branch : develop
This commit is contained in:
parent
b46e384ca7
commit
a4b2bb905f
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
#include "tmainwindow.h"
|
#include "tmainwindow.h"
|
||||||
#include "mapplication.h"
|
#include "mapplication.h"
|
||||||
#include "../vmisc/vsysexits.h"
|
|
||||||
|
|
||||||
#include <QMessageBox> // For QT_REQUIRE_VERSION
|
#include <QMessageBox> // For QT_REQUIRE_VERSION
|
||||||
|
|
||||||
|
@ -50,6 +49,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
MApplication app(argc, argv);
|
MApplication app(argc, argv);
|
||||||
app.InitOptions();
|
app.InitOptions();
|
||||||
app.ParseCommandLine(SocketConnection::Client, app.arguments());
|
|
||||||
return app.IsTestMode() ? V_EX_OK : app.exec(); // single return point is always better than more
|
QTimer::singleShot(0, &app, SLOT(ProcessCMD()));
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,31 +234,31 @@ bool MApplication::notify(QObject *receiver, QEvent *event)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")),
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")),
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionConversionError &e)
|
catch (const VExceptionConversionError &e)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")),
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionEmptyParameter &e)
|
catch (const VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")),
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionWrongId &e)
|
catch (const VExceptionWrongId &e)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")),
|
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VException &e)
|
catch (const VException &e)
|
||||||
{
|
{
|
||||||
|
@ -271,12 +271,12 @@ bool MApplication::notify(QObject *receiver, QEvent *event)
|
||||||
catch (const qmu::QmuParserError &e)
|
catch (const qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s", qUtf8Printable(tr("Parser error: %1. Program will be terminated.").arg(e.GetMsg())));
|
qCCritical(mApp, "%s", qUtf8Printable(tr("Parser error: %1. Program will be terminated.").arg(e.GetMsg())));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
qCCritical(mApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what())));
|
qCCritical(mApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what())));
|
||||||
std::exit(V_EX_SOFTWARE);
|
exit(V_EX_SOFTWARE);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,8 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
||||||
stream << QCoreApplication::arguments().join(";;");
|
stream << QCoreApplication::arguments().join(";;");
|
||||||
stream.flush();
|
stream.flush();
|
||||||
socket.waitForBytesWritten();
|
socket.waitForBytesWritten();
|
||||||
std::exit(V_EX_OK);
|
qApp->exit(V_EX_OK);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName));
|
qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName));
|
||||||
|
@ -640,7 +641,15 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
||||||
for (int i = 0; i < args.size(); ++i)
|
for (int i = 0; i < args.size(); ++i)
|
||||||
{
|
{
|
||||||
NewMainWindow();
|
NewMainWindow();
|
||||||
MainWindow()->LoadFile(args.at(i));
|
if (not MainWindow()->LoadFile(args.at(i)))
|
||||||
|
{
|
||||||
|
if (testMode)
|
||||||
|
{
|
||||||
|
return; // process only one input file
|
||||||
|
}
|
||||||
|
delete MainWindow();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (flagSize)
|
if (flagSize)
|
||||||
{
|
{
|
||||||
|
@ -670,6 +679,11 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
||||||
parser.showHelp(V_EX_USAGE);
|
parser.showHelp(V_EX_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (testMode)
|
||||||
|
{
|
||||||
|
qApp->exit(V_EX_OK); // close program after processing in console mode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -710,6 +724,12 @@ TMainWindow *MApplication::NewMainWindow()
|
||||||
return tape;
|
return tape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MApplication::ProcessCMD()
|
||||||
|
{
|
||||||
|
ParseCommandLine(SocketConnection::Client, arguments());
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MApplication::OpenFile(const QString &path)
|
void MApplication::OpenFile(const QString &path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
TMainWindow *NewMainWindow();
|
TMainWindow *NewMainWindow();
|
||||||
|
void ProcessCMD();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void InitTrVars() Q_DECL_OVERRIDE;
|
virtual void InitTrVars() Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -160,7 +160,7 @@ void TMainWindow::SetPUnit(Unit unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::LoadFile(const QString &path)
|
bool TMainWindow::LoadFile(const QString &path)
|
||||||
{
|
{
|
||||||
if (m == nullptr)
|
if (m == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -169,12 +169,9 @@ void TMainWindow::LoadFile(const QString &path)
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path)));
|
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path)));
|
||||||
if (qApp->IsTestMode())
|
if (qApp->IsTestMode())
|
||||||
{
|
{
|
||||||
std::exit(V_EX_NOINPUT);
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if file already opened
|
// Check if file already opened
|
||||||
|
@ -185,7 +182,7 @@ void TMainWindow::LoadFile(const QString &path)
|
||||||
{
|
{
|
||||||
list.at(i)->activateWindow();
|
list.at(i)->activateWindow();
|
||||||
close();
|
close();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,12 +193,9 @@ void TMainWindow::LoadFile(const QString &path)
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
if (qApp->IsTestMode())
|
if (qApp->IsTestMode())
|
||||||
{
|
{
|
||||||
std::exit(V_EX_NOINPUT);
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -278,20 +272,18 @@ void TMainWindow::LoadFile(const QString &path)
|
||||||
|
|
||||||
if (qApp->IsTestMode())
|
if (qApp->IsTestMode())
|
||||||
{
|
{
|
||||||
std::exit(V_EX_NOINPUT);
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qApp->NewMainWindow();
|
qApp->NewMainWindow();
|
||||||
qApp->MainWindow()->LoadFile(path);
|
return qApp->MainWindow()->LoadFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
void SetPUnit(Unit unit);
|
void SetPUnit(Unit unit);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void LoadFile(const QString &path);
|
bool LoadFile(const QString &path);
|
||||||
void FileNew();
|
void FileNew();
|
||||||
void OpenIndividual();
|
void OpenIndividual();
|
||||||
void OpenStandard();
|
void OpenStandard();
|
||||||
|
|
|
@ -294,31 +294,31 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")),
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")),
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error bad id. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionConversionError &e)
|
catch (const VExceptionConversionError &e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")),
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionEmptyParameter &e)
|
catch (const VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")),
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VExceptionWrongId &e)
|
catch (const VExceptionWrongId &e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")),
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id. Program will be terminated.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (const VException &e)
|
catch (const VException &e)
|
||||||
{
|
{
|
||||||
|
@ -331,12 +331,12 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
||||||
catch (const qmu::QmuParserError &e)
|
catch (const qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s", qUtf8Printable(tr("Parser error: %1. Program will be terminated.").arg(e.GetMsg())));
|
qCCritical(vApp, "%s", qUtf8Printable(tr("Parser error: %1. Program will be terminated.").arg(e.GetMsg())));
|
||||||
std::exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what())));
|
qCCritical(vApp, "%s", qUtf8Printable(tr("Exception thrown: %1. Program will be terminated.").arg(e.what())));
|
||||||
std::exit(V_EX_SOFTWARE);
|
exit(V_EX_SOFTWARE);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../options.h"
|
#include "../options.h"
|
||||||
#include "../core/vapplication.h"
|
#include "../core/vapplication.h"
|
||||||
#include "../vmisc/vsettings.h"
|
#include "../vmisc/vsettings.h"
|
||||||
|
#include "../ifc/exception/vexception.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -88,8 +89,8 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical() << tr("The base filename has not match regular expression.");
|
VException e(tr("The base filename has not match regular expression."));
|
||||||
std::exit(V_EX_USAGE);
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,15 +120,15 @@ void DialogSaveLayout::SelectFormate(const size_t formate)
|
||||||
{
|
{
|
||||||
if (formate >= availFormats.size())
|
if (formate >= availFormats.size())
|
||||||
{
|
{
|
||||||
qCritical() << tr("Tried to use out of range format number.");
|
VException e(tr("Tried to use out of range format number."));
|
||||||
std::exit(V_EX_USAGE);
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = ui->comboBoxFormat->findData(availFormats[formate].pair.second);
|
const int i = ui->comboBoxFormat->findData(availFormats[formate].pair.second);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
qCritical() << tr("Selected not present format.");
|
VException e(tr("Selected not present format."));
|
||||||
std::exit(V_EX_USAGE);
|
throw e;
|
||||||
}
|
}
|
||||||
ui->comboBoxFormat->setCurrentIndex(i);
|
ui->comboBoxFormat->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
|
@ -164,8 +165,8 @@ void DialogSaveLayout::SetDestinationPath(const QString &cmdDestinationPath)
|
||||||
QDir dir;
|
QDir dir;
|
||||||
if (not dir.cd(cmdDestinationPath))
|
if (not dir.cd(cmdDestinationPath))
|
||||||
{
|
{
|
||||||
qCritical() << tr("The destination directory doesn't exists or is not readable.");
|
VException e(tr("The destination directory doesn't exists or is not readable."));
|
||||||
std::exit(V_EX_DATAERR);
|
throw e;
|
||||||
}
|
}
|
||||||
path = dir.absolutePath();
|
path = dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,52 +58,7 @@ int main(int argc, char *argv[])
|
||||||
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
||||||
app.setMainWindow(&w);
|
app.setMainWindow(&w);
|
||||||
|
|
||||||
auto args = app.CommandLine()->OptInputFileNames();
|
QTimer::singleShot(0, &w, SLOT(ProcessCMD()));
|
||||||
|
|
||||||
//Before we load pattern show window.
|
return app.exec();
|
||||||
if (VApplication::CheckGUI())
|
|
||||||
{
|
|
||||||
w.show();
|
|
||||||
w.ReopenFilesAfterCrash(args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (args.size() != 1)
|
|
||||||
{
|
|
||||||
qCritical() << QCoreApplication::translate("vmain", "Please, provide one input file.");
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0, sz = args.size(); i < sz; ++i)
|
|
||||||
{
|
|
||||||
const bool loaded = w.LoadPattern(args.at(static_cast<int>(i)), app.CommandLine()->OptMeasurePath());
|
|
||||||
|
|
||||||
if (app.CommandLine()->IsTestModeEnabled() || app.CommandLine()->IsExportEnabled())
|
|
||||||
{
|
|
||||||
if (app.CommandLine()->IsSetGradationSize())
|
|
||||||
{
|
|
||||||
w.SetSize(app.CommandLine()->OptGradationSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app.CommandLine()->IsSetGradationHeight())
|
|
||||||
{
|
|
||||||
w.SetHeight(app.CommandLine()->OptGradationHeight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not app.CommandLine()->IsTestModeEnabled())
|
|
||||||
{
|
|
||||||
if (app.CommandLine()->IsExportEnabled())
|
|
||||||
{
|
|
||||||
if (loaded)
|
|
||||||
{
|
|
||||||
w.DoExport(app.CommandLine());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (VApplication::CheckGUI()) ? app.exec() : V_EX_OK; // single return point is always better than more
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,14 +290,11 @@ QSharedPointer<VMeasurements> MainWindow::OpenMeasurementFile(const QString &pat
|
||||||
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.")));
|
||||||
m->clear();
|
m->clear();
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return m;
|
qApp->exit(V_EX_DATAERR);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_DATAERR);
|
|
||||||
}
|
}
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,14 +303,11 @@ QSharedPointer<VMeasurements> MainWindow::OpenMeasurementFile(const QString &pat
|
||||||
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()));
|
||||||
m->clear();
|
m->clear();
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return m;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -345,14 +339,11 @@ 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()));
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -370,14 +361,11 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
|
||||||
if (qApp->patternType() != m->Type())
|
if (qApp->patternType() != m->Type())
|
||||||
{
|
{
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Measurement files types have not match.")));
|
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Measurement files types have not match.")));
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_DATAERR);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_DATAERR);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->Type() == MeasurementsType::Standard)
|
if (m->Type() == MeasurementsType::Standard)
|
||||||
|
@ -395,14 +383,11 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
|
||||||
{
|
{
|
||||||
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()));
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2207,83 +2192,65 @@ 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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString patternPiece = QString();
|
QString patternPiece = QString();
|
||||||
|
@ -2323,28 +2290,22 @@ 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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3302,14 +3263,11 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
Clear();
|
Clear();
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On this stage scene empty. Fit scene size to view size
|
// On this stage scene empty. Fit scene size to view size
|
||||||
|
@ -3344,14 +3302,11 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
Clear();
|
Clear();
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
|
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
|
||||||
.arg(path)));
|
.arg(path)));
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not LoadMeasurements(path))
|
if (not LoadMeasurements(path))
|
||||||
|
@ -3359,14 +3314,11 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
|
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.")
|
||||||
.arg(path)));
|
.arg(path)));
|
||||||
Clear();
|
Clear();
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3382,14 +3334,11 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
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()));
|
||||||
Clear();
|
Clear();
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return false;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
@ -3747,15 +3696,33 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
|
||||||
if (details->count() == 0)
|
if (details->count() == 0)
|
||||||
{
|
{
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene.")));
|
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene.")));
|
||||||
std::exit(V_EX_DATAERR);
|
qApp->exit(V_EX_DATAERR);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrepareDetailsForLayout(details);
|
PrepareDetailsForLayout(details);
|
||||||
LayoutSettings(*settings.get());
|
if (LayoutSettings(*settings.get()))
|
||||||
DialogSaveLayout dialog(scenes.size(), expParams->OptBaseName(), this);
|
{
|
||||||
dialog.SetDestinationPath(expParams->OptDestinationPath());
|
try
|
||||||
dialog.SelectFormate(expParams->OptExportType());
|
{
|
||||||
ExportLayout(dialog);
|
DialogSaveLayout dialog(scenes.size(), expParams->OptBaseName(), this);
|
||||||
|
dialog.SetDestinationPath(expParams->OptDestinationPath());
|
||||||
|
dialog.SelectFormate(expParams->OptExportType());
|
||||||
|
ExportLayout(dialog);
|
||||||
|
}
|
||||||
|
catch (const VException &e)
|
||||||
|
{
|
||||||
|
qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage()));
|
||||||
|
qApp->exit(V_EX_DATAERR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->exit(V_EX_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -3833,3 +3800,66 @@ void MainWindow::SetHeight(const QString &text)
|
||||||
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("The method %1 does nothing in GUI mode").arg(Q_FUNC_INFO)));
|
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("The method %1 does nothing in GUI mode").arg(Q_FUNC_INFO)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::ProcessCMD()
|
||||||
|
{
|
||||||
|
auto args = qApp->CommandLine()->OptInputFileNames();
|
||||||
|
|
||||||
|
//Before we load pattern show window.
|
||||||
|
if (VApplication::CheckGUI())
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
ReopenFilesAfterCrash(args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args.size() != 1)
|
||||||
|
{
|
||||||
|
qCritical() << tr("Please, provide one input file.");
|
||||||
|
qApp->exit(V_EX_NOINPUT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0, sz = args.size(); i < sz; ++i)
|
||||||
|
{
|
||||||
|
const bool loaded = LoadPattern(args.at(static_cast<int>(i)), qApp->CommandLine()->OptMeasurePath());
|
||||||
|
|
||||||
|
if (not loaded && not VApplication::CheckGUI())
|
||||||
|
{
|
||||||
|
return; // process only one input file
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qApp->CommandLine()->IsTestModeEnabled() || qApp->CommandLine()->IsExportEnabled())
|
||||||
|
{
|
||||||
|
if (qApp->CommandLine()->IsSetGradationSize())
|
||||||
|
{
|
||||||
|
SetSize(qApp->CommandLine()->OptGradationSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qApp->CommandLine()->IsSetGradationHeight())
|
||||||
|
{
|
||||||
|
SetHeight(qApp->CommandLine()->OptGradationHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not qApp->CommandLine()->IsTestModeEnabled())
|
||||||
|
{
|
||||||
|
if (qApp->CommandLine()->IsExportEnabled())
|
||||||
|
{
|
||||||
|
if (loaded)
|
||||||
|
{
|
||||||
|
DoExport(qApp->CommandLine());
|
||||||
|
return; // process only one input file
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not VApplication::CheckGUI())
|
||||||
|
{
|
||||||
|
qApp->exit(V_EX_OK);// close program after processing in console mode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -60,14 +60,9 @@ public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
virtual ~MainWindow() Q_DECL_OVERRIDE;
|
virtual ~MainWindow() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString());
|
|
||||||
void ReopenFilesAfterCrash(QStringList &args);
|
|
||||||
void DoExport(const VCommandLinePtr& expParams);
|
|
||||||
|
|
||||||
void SetSize(const QString &text);
|
|
||||||
void SetHeight(const QString & text);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void ProcessCMD();
|
||||||
|
|
||||||
void mouseMove(const QPointF &scenePos);
|
void mouseMove(const QPointF &scenePos);
|
||||||
void ArrowTool();
|
void ArrowTool();
|
||||||
|
|
||||||
|
@ -309,6 +304,13 @@ private:
|
||||||
|
|
||||||
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const;
|
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const;
|
||||||
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) const;
|
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath) const;
|
||||||
|
|
||||||
|
bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString());
|
||||||
|
void ReopenFilesAfterCrash(QStringList &args);
|
||||||
|
void DoExport(const VCommandLinePtr& expParams);
|
||||||
|
|
||||||
|
void SetSize(const QString &text);
|
||||||
|
void SetHeight(const QString & text);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -101,7 +101,7 @@ void MainWindowsNoGUI::ToolLayoutSettings(bool checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator)
|
bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator)
|
||||||
{
|
{
|
||||||
lGenerator.SetDetails(listDetails);
|
lGenerator.SetDetails(listDetails);
|
||||||
DialogLayoutProgress progress(listDetails.count(), this);
|
DialogLayoutProgress progress(listDetails.count(), this);
|
||||||
|
@ -135,14 +135,14 @@ void MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator)
|
||||||
isLayoutStale = false;
|
isLayoutStale = false;
|
||||||
break;
|
break;
|
||||||
case LayoutErrors::ProcessStoped:
|
case LayoutErrors::ProcessStoped:
|
||||||
break;
|
|
||||||
case LayoutErrors::PrepareLayoutError:
|
case LayoutErrors::PrepareLayoutError:
|
||||||
case LayoutErrors::EmptyPaperError:
|
case LayoutErrors::EmptyPaperError:
|
||||||
break;
|
return false;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
|
void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
|
||||||
|
@ -163,11 +163,10 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::exit(V_EX_DATAERR);
|
qApp->exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void MainWindowsNoGUI::ExportLayoutAs()
|
void MainWindowsNoGUI::ExportLayoutAs()
|
||||||
{
|
{
|
||||||
if (isLayoutStale)
|
if (isLayoutStale)
|
||||||
|
@ -177,14 +176,24 @@ void MainWindowsNoGUI::ExportLayoutAs()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DialogSaveLayout dialog(scenes.size(), FileName(), this);
|
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Rejected)
|
try
|
||||||
{
|
{
|
||||||
|
DialogSaveLayout dialog(scenes.size(), FileName(), this);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Rejected)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExportLayout(dialog);
|
||||||
|
}
|
||||||
|
catch (const VException &e)
|
||||||
|
{
|
||||||
|
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")),
|
||||||
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportLayout(dialog);
|
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ protected:
|
||||||
virtual void CleanLayout()=0;
|
virtual void CleanLayout()=0;
|
||||||
virtual void PrepareSceneList()=0;
|
virtual void PrepareSceneList()=0;
|
||||||
QIcon ScenePreview(int i) const;
|
QIcon ScenePreview(int i) const;
|
||||||
void LayoutSettings(VLayoutGenerator& lGenerator);
|
bool LayoutSettings(VLayoutGenerator& lGenerator);
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MainWindowsNoGUI)
|
Q_DISABLE_COPY(MainWindowsNoGUI)
|
||||||
|
|
||||||
|
|
|
@ -358,83 +358,65 @@ void VPattern::LiteParseTree(const Document &parse)
|
||||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (const VExceptionConversionError &e)
|
catch (const VExceptionConversionError &e)
|
||||||
{
|
{
|
||||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
|
qCCritical(vXML, "%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()));
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (const VExceptionEmptyParameter &e)
|
catch (const VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (const VExceptionWrongId &e)
|
catch (const VExceptionWrongId &e)
|
||||||
{
|
{
|
||||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc &)
|
catch (const std::bad_alloc &)
|
||||||
{
|
{
|
||||||
qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
|
qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
|
||||||
emit SetEnabledGUI(false);
|
emit SetEnabledGUI(false);
|
||||||
if (VApplication::CheckGUI())
|
if (not VApplication::CheckGUI())
|
||||||
{
|
{
|
||||||
return;
|
qApp->exit(V_EX_NOINPUT);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::exit(V_EX_NOINPUT);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore name current pattern piece
|
// Restore name current pattern piece
|
||||||
|
|
|
@ -63,6 +63,8 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||||
|
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
|
||||||
|
connect(this, &QApplication::aboutToQuit, this, &VAbstractApplication::SyncSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -135,6 +137,15 @@ double VAbstractApplication::fromPixel(double pix) const
|
||||||
return FromPixel(pix, _patternUnit);
|
return FromPixel(pix, _patternUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractApplication::SyncSettings()
|
||||||
|
{
|
||||||
|
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
|
||||||
|
// instance. Solution is to call sync() before quit.
|
||||||
|
// Connect this slot with VApplication::aboutToQuit.
|
||||||
|
Settings()->sync();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractApplication::LoadTranslation(const QString &locale)
|
void VAbstractApplication::LoadTranslation(const QString &locale)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,7 @@ class QUndoStack;
|
||||||
|
|
||||||
class VAbstractApplication : public QApplication
|
class VAbstractApplication : public QApplication
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VAbstractApplication(int &argc, char ** argv);
|
VAbstractApplication(int &argc, char ** argv);
|
||||||
virtual ~VAbstractApplication() Q_DECL_OVERRIDE;
|
virtual ~VAbstractApplication() Q_DECL_OVERRIDE;
|
||||||
|
@ -92,6 +93,9 @@ public:
|
||||||
|
|
||||||
QUndoStack *getUndoStack() const;
|
QUndoStack *getUndoStack() const;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void SyncSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUndoStack *undoStack;
|
QUndoStack *undoStack;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user