diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp
index 4cb8247e7..b6887ba6e 100644
--- a/src/app/valentina/mainwindow.cpp
+++ b/src/app/valentina/mainwindow.cpp
@@ -3854,7 +3854,7 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
}
//---------------------------------------------------------------------------------------------------------------------
-void MainWindow::SetSize(const QString &text)
+bool MainWindow::SetSize(const QString &text)
{
if (not qApp->IsGUIMode())
{
@@ -3870,29 +3870,34 @@ void MainWindow::SetSize(const QString &text)
}
else
{
- qCWarning(vMainWindow, "%s",
+ qCCritical(vMainWindow, "%s",
qUtf8Printable(tr("Not supported size value '%1' for this pattern file.").arg(text)));
+ return false;
}
}
else
{
- qCWarning(vMainWindow, "%s",
+ qCCritical(vMainWindow, "%s",
qUtf8Printable(tr("Couldn't set size. Need a file with standard measurements.")));
+ return false;
}
}
else
{
- qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Couldn't set size. File wasn't opened.")));
+ qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Couldn't set size. File wasn't opened.")));
+ return false;
}
}
else
{
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("The method %1 does nothing in GUI mode").arg(Q_FUNC_INFO)));
+ return false;
}
+ return true;
}
//---------------------------------------------------------------------------------------------------------------------
-void MainWindow::SetHeight(const QString &text)
+bool MainWindow::SetHeight(const QString &text)
{
if (not qApp->IsGUIMode())
{
@@ -3908,25 +3913,30 @@ void MainWindow::SetHeight(const QString &text)
}
else
{
- qCWarning(vMainWindow, "%s",
+ qCCritical(vMainWindow, "%s",
qUtf8Printable(tr("Not supported height value '%1' for this pattern file.").arg(text)));
+ return false;
}
}
else
{
- qCWarning(vMainWindow, "%s",
+ qCCritical(vMainWindow, "%s",
qUtf8Printable(tr("Couldn't set height. Need a file with standard measurements.")));
+ return false;
}
}
else
{
- qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Couldn't set height. File wasn't opened.")));
+ qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Couldn't set height. File wasn't opened.")));
+ return false;
}
}
else
{
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("The method %1 does nothing in GUI mode").arg(Q_FUNC_INFO)));
+ return false;
}
+ return true;
}
//---------------------------------------------------------------------------------------------------------------------
@@ -3960,16 +3970,18 @@ void MainWindow::ProcessCMD()
return; // process only one input file
}
+ bool hSetted = true;
+ bool sSetted = true;
if (loaded && (cmd->IsTestModeEnabled() || cmd->IsExportEnabled()))
{
if (cmd->IsSetGradationSize())
{
- SetSize(cmd->OptGradationSize());
+ sSetted = SetSize(cmd->OptGradationSize());
}
if (cmd->IsSetGradationHeight())
{
- SetHeight(cmd->OptGradationHeight());
+ hSetted = SetHeight(cmd->OptGradationHeight());
}
}
@@ -3977,11 +3989,16 @@ void MainWindow::ProcessCMD()
{
if (cmd->IsExportEnabled())
{
- if (loaded)
+ if (loaded && hSetted && sSetted)
{
DoExport(cmd);
return; // process only one input file
}
+ else
+ {
+ qApp->exit(V_EX_DATAERR);
+ return;
+ }
break;
}
}
diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h
index 1be677abf..dcdd60105 100644
--- a/src/app/valentina/mainwindow.h
+++ b/src/app/valentina/mainwindow.h
@@ -312,8 +312,8 @@ private:
void ReopenFilesAfterCrash(QStringList &args);
void DoExport(const VCommandLinePtr& expParams);
- void SetSize(const QString &text);
- void SetHeight(const QString & text);
+ bool SetSize(const QString &text);
+ bool SetHeight(const QString & text);
QString GetPatternFileName();
QString GetMeasurementFileName();
diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro
index db9955b56..ce95d7e2e 100644
--- a/src/test/ValentinaTest/ValentinaTest.pro
+++ b/src/test/ValentinaTest/ValentinaTest.pro
@@ -230,7 +230,12 @@ VALENTINA_TEST_FILES += \
tst_valentina/empty.val \
tst_valentina/issue_372.val \
tst_valentina/wrong_obj_type.val \
- tst_valentina/text.val
+ tst_valentina/text.val \
+ tst_valentina/glimited_no_m.val \
+ tst_valentina/glimited_vit.val \
+ tst_valentina/glimited.vit \
+ tst_valentina/glimited_vst.val \
+ tst_valentina/glimited.vst
# Compilation will fail without this files after we added them to this section.
OTHER_FILES += \
diff --git a/src/test/ValentinaTest/tst_valentina/glimited.vit b/src/test/ValentinaTest/tst_valentina/glimited.vit
new file mode 100644
index 000000000..32557f35e
--- /dev/null
+++ b/src/test/ValentinaTest/tst_valentina/glimited.vit
@@ -0,0 +1,19 @@
+
+
+
+ 0.3.3
+ false
+
+ cm
+ 998
+
+
+
+ 1800-01-01
+ unknown
+
+
+
+
+
+
diff --git a/src/test/ValentinaTest/tst_valentina/glimited.vst b/src/test/ValentinaTest/tst_valentina/glimited.vst
new file mode 100644
index 000000000..16275a966
--- /dev/null
+++ b/src/test/ValentinaTest/tst_valentina/glimited.vst
@@ -0,0 +1,14 @@
+
+
+
+ 0.4.2
+ false
+
+ cm
+ 998
+
+
+
+
+
+
diff --git a/src/test/ValentinaTest/tst_valentina/glimited_no_m.val b/src/test/ValentinaTest/tst_valentina/glimited_no_m.val
new file mode 100644
index 000000000..36b65faf2
--- /dev/null
+++ b/src/test/ValentinaTest/tst_valentina/glimited_no_m.val
@@ -0,0 +1,19 @@
+
+
+
+ 0.2.1
+ cm
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/ValentinaTest/tst_valentina/glimited_vit.val b/src/test/ValentinaTest/tst_valentina/glimited_vit.val
new file mode 100644
index 000000000..21c479f80
--- /dev/null
+++ b/src/test/ValentinaTest/tst_valentina/glimited_vit.val
@@ -0,0 +1,19 @@
+
+
+
+ 0.2.1
+ cm
+
+
+
+ glimited.vit
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/ValentinaTest/tst_valentina/glimited_vst.val b/src/test/ValentinaTest/tst_valentina/glimited_vst.val
new file mode 100644
index 000000000..e86a62aa6
--- /dev/null
+++ b/src/test/ValentinaTest/tst_valentina/glimited_vst.val
@@ -0,0 +1,37 @@
+
+
+
+ 0.2.1
+ cm
+
+
+
+
+
+
+
+ glimited.vst
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/ValentinaTest/tst_valentinacommandline.cpp b/src/test/ValentinaTest/tst_valentinacommandline.cpp
index 6141e2d5b..9de8cf9da 100644
--- a/src/test/ValentinaTest/tst_valentinacommandline.cpp
+++ b/src/test/ValentinaTest/tst_valentinacommandline.cpp
@@ -112,6 +112,30 @@ void TST_ValentinaCommandLine::ExportMode_data() const
<< QString("-p;;0;;-d;;%1;;-b;;output").arg(tmp)
<< true
<< V_EX_OK;
+
+ QTest::newRow("A file with limited gradation. Standard measurements. Wrong data.")
+ << "glimited_vst.val"
+ << QString("-p;;0;;-d;;%1;;--gsize;;46;;--gheight;;164;;-b;;output").arg(tmp)
+ << false
+ << V_EX_DATAERR;
+
+ QTest::newRow("A file with limited gradation. Standard measurements. Correct data.")
+ << "glimited_vst.val"
+ << QString("-p;;0;;-d;;%1;;--gsize;;40;;--gheight;;134;;-b;;output").arg(tmp)
+ << true
+ << V_EX_OK;
+
+ QTest::newRow("A file with limited gradation. Individual measurements.")
+ << "glimited_vit.val"
+ << QString("-p;;0;;-d;;%1;;--gsize;;40;;--gheight;;134;;-b;;output").arg(tmp)
+ << false
+ << V_EX_DATAERR;
+
+ QTest::newRow("A file with limited gradation. No measurements.")
+ << "glimited_no_m.val"
+ << QString("-p;;0;;-d;;%1;;--gsize;;40;;--gheight;;134;;-b;;output").arg(tmp)
+ << false
+ << V_EX_DATAERR;
}
//---------------------------------------------------------------------------------------------------------------------