Make load function return true/false to fine control DoExport
--HG-- branch : develop
This commit is contained in:
parent
505e938949
commit
f5d5c9fd57
|
@ -29,11 +29,14 @@ inline QTextStream& vStdErr()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
NORET_ATTR inline void AppAbort(const QString& text, int code = GENERAL_ERROR_STATUS)
|
NORET_ATTR inline void AppAbort(const QString& text = QString(), int code = GENERAL_ERROR_STATUS)
|
||||||
{
|
{
|
||||||
//well ..std::runtime_error was leading to zombies in memory and a lot of dumping all the time ...better to do just exit
|
//well ..std::runtime_error was leading to zombies in memory and a lot of dumping all the time ...better to do just exit
|
||||||
//possibly compiler do not have -fexceptions set
|
//possibly compiler do not have -fexceptions set
|
||||||
|
if (!text.isEmpty())
|
||||||
|
{
|
||||||
vStdErr() << text << "\n";
|
vStdErr() << text << "\n";
|
||||||
|
}
|
||||||
std::exit(code);
|
std::exit(code);
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -69,10 +69,13 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
for (size_t i=0, sz = args.size(); i < sz;++i)
|
for (size_t i=0, sz = args.size(); i < sz;++i)
|
||||||
{
|
{
|
||||||
w.LoadPattern(args.at(static_cast<int>(i)), app.CommandLine()->OptMeasurePath());
|
bool loaded = w.LoadPattern(args.at(static_cast<int>(i)), app.CommandLine()->OptMeasurePath());
|
||||||
if (app.CommandLine()->IsExportEnabled())
|
if (app.CommandLine()->IsExportEnabled())
|
||||||
|
{
|
||||||
|
if (loaded)
|
||||||
{
|
{
|
||||||
w.DoExport(app.CommandLine());
|
w.DoExport(app.CommandLine());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3024,21 +3024,21 @@ MainWindow::~MainWindow()
|
||||||
* @brief LoadPattern open pattern file.
|
* @brief LoadPattern open pattern file.
|
||||||
* @param fileName name of file.
|
* @param fileName name of file.
|
||||||
*/
|
*/
|
||||||
void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasureFile)
|
bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasureFile)
|
||||||
{
|
{
|
||||||
qCDebug(vMainWindow, "Loading new file %s.", fileName.toUtf8().constData());
|
qCDebug(vMainWindow, "Loading new file %s.", fileName.toUtf8().constData());
|
||||||
|
|
||||||
//We have unsaved changes or load more then one file per time
|
//We have unsaved changes or load more then one file per time
|
||||||
if (OpenNewValentina(fileName))
|
if (OpenNewValentina(fileName))
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
{
|
{
|
||||||
qCDebug(vMainWindow, "Got empty file.");
|
qCDebug(vMainWindow, "Got empty file.");
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||||
|
@ -3057,7 +3057,7 @@ void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
{
|
{
|
||||||
qCCritical(vMainWindow, "%s", tr("This file already opened in another window.").toUtf8().constData());
|
qCCritical(vMainWindow, "%s", tr("This file already opened in another window.").toUtf8().constData());
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||||
|
@ -3092,13 +3092,13 @@ void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not LoadMeasurements(path))
|
if (not LoadMeasurements(path))
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3120,7 +3120,7 @@ void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
vStdErr() << tr("File error.") << e.MoreInformation() << "\n";
|
vStdErr() << tr("File error.") << e.MoreInformation() << "\n";
|
||||||
}
|
}
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
@ -3148,6 +3148,7 @@ void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
|
|
||||||
ui->actionDraw->setChecked(true);
|
ui->actionDraw->setChecked(true);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -60,7 +60,7 @@ class MainWindow : public MainWindowsNoGUI
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
virtual ~MainWindow() Q_DECL_OVERRIDE;
|
virtual ~MainWindow() Q_DECL_OVERRIDE;
|
||||||
void LoadPattern(const QString &curFile, const QString &customMeasureFile = QString());
|
bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString());
|
||||||
void ReopenFilesAfterCrash(QStringList &args);
|
void ReopenFilesAfterCrash(QStringList &args);
|
||||||
|
|
||||||
void DoExport(const VCommandLinePtr& expParams);
|
void DoExport(const VCommandLinePtr& expParams);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user