Resolved issue #256. Crash if open pattern with wrong measurements file.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-22 15:29:16 +02:00
parent dfe5c0c601
commit 6e394a20f2
10 changed files with 263 additions and 9 deletions

View file

@ -555,8 +555,9 @@ QString VCommandLine::OptMeasurePath() const
{
QString measure;
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_MEASUREFILE)))
&& IsExportEnabled() //todo: don't want yet to allow user set measure file for general loading, because need to fix multiply opened windows as well
)
&& (IsExportEnabled() || IsTestModeEnabled()))
//todo: don't want yet to allow user set measure file for general loading,
//because need to fix multiply opened windows as well
{
measure = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_MEASUREFILE)));
}

View file

@ -239,7 +239,14 @@ VALENTINA_TEST_FILES += \
tst_valentina/glimited_vit.val \
tst_valentina/glimited.vit \
tst_valentina/glimited_vst.val \
tst_valentina/glimited.vst
tst_valentina/glimited.vst \
tst_valentina/issue_256.val \
tst_valentina/issue_256_wrong_path.val \
tst_valentina/issue_256_correct.vit \
tst_valentina/issue_256_wrong.vit \
tst_valentina/issue_256_correct.vst \
tst_valentina/issue_256_wrong.vit
# Compilation will fail without this files after we added them to this section.
OTHER_FILES += \

View file

@ -0,0 +1,37 @@
<?xml version='1.0' encoding='UTF-8'?>
<pattern>
<!--Pattern created with Valentina (http://www.valentina-project.org/).-->
<version>0.2.2</version>
<unit>cm</unit>
<author/>
<description/>
<notes/>
<measurements>issue_256_correct.vit</measurements>
<increments/>
<draw name="Pattern piece 1">
<calculation>
<point type="single" x="1.34938" y="1.24354" id="1" name="A" mx="0.132292" my="0.264583"/>
<point type="endLine" typeLine="hair" id="2" name="A1" basePoint="1" mx="0.175422" lineColor="black" angle="0" my="0.27896" length="height_scapula/10"/>
<point type="endLine" typeLine="hair" id="3" name="A2" basePoint="1" mx="0.132292" lineColor="black" angle="269.719" my="0.264583" length="Line_A_A1"/>
<point type="pointOfIntersection" id="4" name="A3" firstPoint="2" secondPoint="3" mx="0.132292" my="0.264583"/>
<line typeLine="hair" id="5" firstPoint="3" secondPoint="4" lineColor="black"/>
<line typeLine="hair" id="6" firstPoint="2" secondPoint="4" lineColor="black"/>
</calculation>
<modeling>
<point type="modeling" id="7" idObject="1" mx="0.0264587" my="0.291041"/>
<point type="modeling" id="8" idObject="2" mx="-1.85208" my="0.264583"/>
<point type="modeling" id="9" idObject="4" mx="-2.03729" my="-1.71979"/>
<point type="modeling" id="10" idObject="3" mx="0.47625" my="-1.95792"/>
<point type="modeling" id="11" idObject="1" mx="0.0264587" my="0.291041"/>
</modeling>
<details>
<detail closed="1" id="12" name="Detail" supplement="1" width="1" mx="0.185208" my="-0.079375">
<node type="NodePoint" nodeType="Contour" idObject="7" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="8" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="9" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="10" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="11" mx="0" my="0"/>
</detail>
</details>
</draw>
</pattern>

View file

@ -0,0 +1,38 @@
<?xml version='1.0' encoding='UTF-8'?>
<vit>
<!--Measurements created with Valentina (http://www.valentina-project.org/).-->
<version>0.3.3</version>
<read-only>false</read-only>
<notes/>
<unit>cm</unit>
<pm_system>998</pm_system>
<personal>
<family-name>Spencer</family-name>
<given-name>Susan</given-name>
<birth-date>1900-01-01</birth-date>
<gender>female</gender>
<email/>
</personal>
<body-measurements>
<m name="height" value="167.64" description="Vertical distance from top of Head to Floor" full_name="Height->Total"/>
<m name="height_neck_back" value="141.5" description="Vertical distance from Neck Back (Nape) to Floor" full_name="Height->Neck Back (Nape)"/>
<m name="height_scapula" value="120" description="Vertical distance from Scapula (Shoulder Blade Tip) to Floor" full_name="Height->Scapula"/>
<m name="height_armpit" value="0" description="Vertical distance from Highbust Side (Armpit) to Floor" full_name="Height->Highbust Side (Armpit)"/>
<m name="height_waist_side" value="101" description="Vertical distance from Waist Side to Floor" full_name="Height->Waist Side"/>
<m name="height_hip" value="82" description="Vertical distance from Hip to Floor" full_name="Height->Hip"/>
<m name="height_gluteal_fold" value="0" description="Vertical distance from Gluteal Fold to Floor" full_name="Height->Gluteal Fold"/>
<m name="height_knee" value="42" description="Vertical distance from Knee to Floor" full_name="Height->Knee"/>
<m name="height_calf" value="30.3" description="Vertical distance from Calf to Floor" full_name="Height->Calf"/>
<m name="height_ankle_high" value="11.5" description="Vertical distance from High Ankle to Floor" full_name="Height->High Ankle"/>
<m name="height_ankle" value="9" description="Vertical distance from Ankle to Floor" full_name="Height->Ankle"/>
<m name="height_highhip" value="0" description="Vertical distance from HighHip to Floor" full_name="Height->HighHip"/>
<m name="height_waist_front" value="101.2" description="Vertical distance from Waist Front to Floor" full_name="Height->Waist Front"/>
<m name="height_bustpoint" value="0" description="Vertical distance from Bustpoint to Floor" full_name="Height->Bustpoint"/>
<m name="height_shoulder_tip" value="0" description="Vertical distance from Shoulder Tip to Floor" full_name="Height->Shoulder Tip"/>
<m name="height_neck_front" value="133" description="Vertical distance from Neck Front to Floor" full_name="Height->Neck Front"/>
<m name="height_neck_side" value="0" description="Vertical distance from Neck Side to Floor" full_name="Height->Neck Side"/>
<m name="height_neck_back_to_knee" value="(height_neck_back - height_knee)" description="Vertical distance from Neck Back (Nape) to Knee" full_name="Height->Neck Back to Knee"/>
<m name="height_waist_side_to_knee" value="(height_waist_side - height_knee)" description="Vertical distance from Waist Side to Knee" full_name="Height->Waist Side to Knee"/>
<m name="height_waist_side_to_hip" value="(height_waist_side - height_hip)" description="Vertical distance from Waist Side to Hip" full_name="Height->Waist Side to Hip"/>
</body-measurements>
</vit>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<vst>
<!--Measurements created with Valentina (http://www.valentina-project.org/).-->
<version>0.4.2</version>
<read-only>false</read-only>
<notes/>
<unit>cm</unit>
<pm_system>998</pm_system>
<size base="50"/>
<height base="176"/>
<body-measurements>
<m name="height_neck_back" base="141.5" size_increase="0" height_increase="0"/>
<m name="height_scapula" base="128" size_increase="0" height_increase="0"/>
<m name="height_armpit" base="0" size_increase="0" height_increase="0"/>
</body-measurements>
</vst>

View file

@ -0,0 +1,37 @@
<?xml version='1.0' encoding='UTF-8'?>
<vit>
<!--Measurements created with Valentina (http://www.valentina-project.org/).-->
<version>0.3.3</version>
<read-only>false</read-only>
<notes/>
<unit>cm</unit>
<pm_system>998</pm_system>
<personal>
<family-name>Spencer</family-name>
<given-name>Susan</given-name>
<birth-date>1900-01-01</birth-date>
<gender>female</gender>
<email/>
</personal>
<body-measurements>
<m name="height" value="167.64" description="Vertical distance from top of Head to Floor" full_name="Height->Total"/>
<m name="height_neck_back" value="141.5" description="Vertical distance from Neck Back (Nape) to Floor" full_name="Height->Neck Back (Nape)"/>
<m name="height_armpit" value="0" description="Vertical distance from Highbust Side (Armpit) to Floor" full_name="Height->Highbust Side (Armpit)"/>
<m name="height_waist_side" value="101" description="Vertical distance from Waist Side to Floor" full_name="Height->Waist Side"/>
<m name="height_hip" value="82" description="Vertical distance from Hip to Floor" full_name="Height->Hip"/>
<m name="height_gluteal_fold" value="0" description="Vertical distance from Gluteal Fold to Floor" full_name="Height->Gluteal Fold"/>
<m name="height_knee" value="42" description="Vertical distance from Knee to Floor" full_name="Height->Knee"/>
<m name="height_calf" value="30.3" description="Vertical distance from Calf to Floor" full_name="Height->Calf"/>
<m name="height_ankle_high" value="11.5" description="Vertical distance from High Ankle to Floor" full_name="Height->High Ankle"/>
<m name="height_ankle" value="9" description="Vertical distance from Ankle to Floor" full_name="Height->Ankle"/>
<m name="height_highhip" value="0" description="Vertical distance from HighHip to Floor" full_name="Height->HighHip"/>
<m name="height_waist_front" value="101.2" description="Vertical distance from Waist Front to Floor" full_name="Height->Waist Front"/>
<m name="height_bustpoint" value="0" description="Vertical distance from Bustpoint to Floor" full_name="Height->Bustpoint"/>
<m name="height_shoulder_tip" value="0" description="Vertical distance from Shoulder Tip to Floor" full_name="Height->Shoulder Tip"/>
<m name="height_neck_front" value="133" description="Vertical distance from Neck Front to Floor" full_name="Height->Neck Front"/>
<m name="height_neck_side" value="0" description="Vertical distance from Neck Side to Floor" full_name="Height->Neck Side"/>
<m name="height_neck_back_to_knee" value="(height_neck_back - height_knee)" description="Vertical distance from Neck Back (Nape) to Knee" full_name="Height->Neck Back to Knee"/>
<m name="height_waist_side_to_knee" value="(height_waist_side - height_knee)" description="Vertical distance from Waist Side to Knee" full_name="Height->Waist Side to Knee"/>
<m name="height_waist_side_to_hip" value="(height_waist_side - height_hip)" description="Vertical distance from Waist Side to Hip" full_name="Height->Waist Side to Hip"/>
</body-measurements>
</vit>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<vst>
<!--Measurements created with Valentina (http://www.valentina-project.org/).-->
<version>0.4.2</version>
<read-only>false</read-only>
<notes/>
<unit>cm</unit>
<pm_system>998</pm_system>
<size base="50"/>
<height base="176"/>
<body-measurements>
<m name="height_neck_back" base="141.5" size_increase="0" height_increase="0"/>
<m name="height_armpit" base="0" size_increase="0" height_increase="0"/>
</body-measurements>
</vst>

View file

@ -0,0 +1,37 @@
<?xml version='1.0' encoding='UTF-8'?>
<pattern>
<!--Pattern created with Valentina (http://www.valentina-project.org/).-->
<version>0.2.2</version>
<unit>cm</unit>
<author/>
<description/>
<notes/>
<measurements>issue_256_correct.vit</measurements>
<increments/>
<draw name="Pattern piece 1">
<calculation>
<point type="single" x="1.34938" y="1.24354" id="1" name="A" mx="0.132292" my="0.264583"/>
<point type="endLine" typeLine="hair" id="2" name="A1" basePoint="1" mx="0.175422" lineColor="black" angle="0" my="0.27896" length="height_scapula/10"/>
<point type="endLine" typeLine="hair" id="3" name="A2" basePoint="1" mx="0.132292" lineColor="black" angle="269.719" my="0.264583" length="Line_A_A1"/>
<point type="pointOfIntersection" id="4" name="A3" firstPoint="2" secondPoint="3" mx="0.132292" my="0.264583"/>
<line typeLine="hair" id="5" firstPoint="3" secondPoint="4" lineColor="black"/>
<line typeLine="hair" id="6" firstPoint="2" secondPoint="4" lineColor="black"/>
</calculation>
<modeling>
<point type="modeling" id="7" idObject="1" mx="0.0264587" my="0.291041"/>
<point type="modeling" id="8" idObject="2" mx="-1.85208" my="0.264583"/>
<point type="modeling" id="9" idObject="4" mx="-2.03729" my="-1.71979"/>
<point type="modeling" id="10" idObject="3" mx="0.47625" my="-1.95792"/>
<point type="modeling" id="11" idObject="1" mx="0.0264587" my="0.291041"/>
</modeling>
<details>
<detail closed="1" id="12" name="Detail" supplement="1" width="1" mx="0.185208" my="-0.079375">
<node type="NodePoint" nodeType="Contour" idObject="7" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="8" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="9" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="10" mx="0" my="0"/>
<node type="NodePoint" nodeType="Contour" idObject="11" mx="0" my="0"/>
</detail>
</details>
</draw>
</pattern>

View file

@ -48,8 +48,8 @@ void TST_ValentinaCommandLine::init()
QFAIL("Fail to remove temp directory.");
}
if (not CopyRecursively(QApplication::applicationDirPath() + QLatin1Char('/') + QLatin1Literal("tst_valentina"),
QApplication::applicationDirPath() + QLatin1Char('/') + tmpTestFolder))
if (not CopyRecursively(QApplication::applicationDirPath() + QDir::separator() + QLatin1Literal("tst_valentina"),
QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder))
{
QFAIL("Fail to prepare files for testing.");
}
@ -91,7 +91,8 @@ void TST_ValentinaCommandLine::OpenPatterns()
int exit;
const bool res = Run(result, exitCode, exit, ValentinaPath(), QStringList() << "--test"
<< QApplication::applicationDirPath() + QLatin1Char('/') + tmpTestFolder + QLatin1Char('/') + file);
<< QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder + QDir::separator() +
file);
QCOMPARE(res, result);
QCOMPARE(exit, exitCode);
@ -106,7 +107,7 @@ void TST_ValentinaCommandLine::ExportMode_data() const
QTest::addColumn<bool>("result");
QTest::addColumn<int>("exitCode");
const QString tmp = QApplication::applicationDirPath() + QLatin1Char('/') + tmpTestFolder;
const QString tmp = QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder;
QTest::newRow("Issue #372")<< "issue_372.val"
<< QString("-p;;0;;-d;;%1;;-b;;output").arg(tmp)
@ -148,8 +149,71 @@ void TST_ValentinaCommandLine::ExportMode()
QFETCH(int, exitCode);
int exit;
const QStringList arg = QStringList() << QApplication::applicationDirPath() + QLatin1Char('/') + tmpTestFolder +
QLatin1Char('/') + file
const QStringList arg = QStringList() << QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder +
QDir::separator() + file
<< arguments.split(";;");
const bool res = Run(result, exitCode, exit, ValentinaPath(), arg);
QCOMPARE(res, result);
QCOMPARE(exit, exitCode);
}
//---------------------------------------------------------------------------------------------------------------------
void TST_ValentinaCommandLine::TestMode_data() const
{
QTest::addColumn<QString>("file");
QTest::addColumn<QString>("arguments");
QTest::addColumn<bool>("result");
QTest::addColumn<int>("exitCode");
const QString tmp = QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder;
QTest::newRow("Issue #256. Correct path.")<< "issue_256.val"
<< QString("--test")
<< true
<< V_EX_OK;
QTest::newRow("Issue #256. Wrong path.")<< "issue_256_wrong_path.vit"
<< QString("--test")
<< false
<< V_EX_NOINPUT;
QTest::newRow("Issue #256. Correct individual measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1Literal("issue_256_correct.vit"))
<< true
<< V_EX_OK;
QTest::newRow("Issue #256. Wrong individual measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1Literal("issue_256_wrong.vit"))
<< false
<< V_EX_NOINPUT;
QTest::newRow("Issue #256. Correct standard measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1Literal("issue_256_correct.vst"))
<< true
<< V_EX_OK;
QTest::newRow("Issue #256. Wrong standard measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1Literal("issue_256_wrong.vst"))
<< false
<< V_EX_NOINPUT;
}
//---------------------------------------------------------------------------------------------------------------------
void TST_ValentinaCommandLine::TestMode()
{
QFETCH(QString, file);
QFETCH(QString, arguments);
QFETCH(bool, result);
QFETCH(int, exitCode);
int exit;
const QStringList arg = QStringList() << QApplication::applicationDirPath() + QDir::separator() + tmpTestFolder +
QDir::separator() + file
<< arguments.split(";;");
const bool res = Run(result, exitCode, exit, ValentinaPath(), arg);

View file

@ -43,6 +43,8 @@ private slots:
void OpenPatterns();
void ExportMode_data() const;
void ExportMode();
void TestMode_data() const;
void TestMode();
void cleanup();
private: