Make load function return true/false to fine control DoExport

--HG--
branch : develop
This commit is contained in:
Alex 2015-08-27 23:02:54 +03:00
parent 505e938949
commit f5d5c9fd57
4 changed files with 23 additions and 16 deletions

View File

@ -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
//possibly compiler do not have -fexceptions set
vStdErr() << text << "\n";
if (!text.isEmpty())
{
vStdErr() << text << "\n";
}
std::exit(code);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -31,8 +31,8 @@
#include <QMessageBox> // For QT_REQUIRE_VERSION
// Lock producing random attribute order in XML
// https://stackoverflow.com/questions/27378143/qt-5-produce-random-attribute-order-in-xml
extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed;
// https://stackoverflow.com/questions/27378143/qt-5-produce-random-attribute-order-in-xml
extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed;
//---------------------------------------------------------------------------------------------------------------------
@ -69,10 +69,13 @@ int main(int argc, char *argv[])
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())
{
w.DoExport(app.CommandLine());
{
if (loaded)
{
w.DoExport(app.CommandLine());
}
break;
}
}

View File

@ -3024,21 +3024,21 @@ MainWindow::~MainWindow()
* @brief LoadPattern open pattern 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());
//We have unsaved changes or load more then one file per time
if (OpenNewValentina(fileName))
{
return;
return false;
}
if (fileName.isEmpty())
{
qCDebug(vMainWindow, "Got empty file.");
Clear();
return;
return false;
}
#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());
Clear();
return;
return false;
}
}
#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())
{
Clear();
return;
return false;
}
if (not LoadMeasurements(path))
{
Clear();
return;
return false;
}
else
{
@ -3119,8 +3119,8 @@ void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
{
vStdErr() << tr("File error.") << e.MoreInformation() << "\n";
}
Clear();
return;
Clear();
return false;
}
#ifdef Q_OS_WIN32
@ -3148,6 +3148,7 @@ void MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
ui->actionDraw->setChecked(true);
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -60,7 +60,7 @@ class MainWindow : public MainWindowsNoGUI
public:
explicit MainWindow(QWidget *parent = nullptr);
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 DoExport(const VCommandLinePtr& expParams);