From 0483dd508eb5d973551425eee19dfc75edd5f002 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 11 Feb 2020 11:29:57 +0200 Subject: [PATCH] Fix generation of recipe. Modeling object can be removed by the garment collector. In this case the recipe generator will complain about a missed object. We can happily ignore this case if we deal with modeling object. --- src/libs/ifc/xml/vtoolrecord.cpp | 12 ++++++++++++ src/libs/ifc/xml/vtoolrecord.h | 2 ++ src/libs/vformat/vpatternrecipe.cpp | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libs/ifc/xml/vtoolrecord.cpp b/src/libs/ifc/xml/vtoolrecord.cpp index 789198185..4741a432b 100644 --- a/src/libs/ifc/xml/vtoolrecord.cpp +++ b/src/libs/ifc/xml/vtoolrecord.cpp @@ -66,3 +66,15 @@ VToolRecord &VToolRecord::operator=(const VToolRecord &record) VToolRecord::VToolRecord(const VToolRecord &record) :id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw()) {} + +//--------------------------------------------------------------------------------------------------------------------- +bool VToolRecord::IsMandatory() const +{ + return typeTool != Tool::Pin + && typeTool != Tool::NodePoint + && typeTool != Tool::NodeArc + && typeTool != Tool::NodeElArc + && typeTool != Tool::NodeSpline + && typeTool != Tool::NodeSplinePath + && typeTool != Tool::PiecePath; +} diff --git a/src/libs/ifc/xml/vtoolrecord.h b/src/libs/ifc/xml/vtoolrecord.h index d9f623eb2..5a388d25a 100644 --- a/src/libs/ifc/xml/vtoolrecord.h +++ b/src/libs/ifc/xml/vtoolrecord.h @@ -56,6 +56,8 @@ public: QString getNameDraw() const; void setNameDraw(const QString &value); + bool IsMandatory() const; + private: /** @brief id tool id. */ quint32 id; diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index 6d1b768ab..57f86b31d 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -286,7 +286,7 @@ QDomElement VPatternRecipe::Step(const VToolRecord &tool) Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history."); const QDomElement domElem = m_pattern->elementById(tool.getId()); - if (not domElem.isElement()) + if (not domElem.isElement() && tool.IsMandatory()) { throw VExceptionInvalidHistory(tr("Can't find element by id '%1'").arg(tool.getId())); }