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.
This commit is contained in:
Roman Telezhynskyi 2020-02-11 11:29:57 +02:00
parent 8eac0d5c66
commit 0483dd508e
3 changed files with 15 additions and 1 deletions

View File

@ -66,3 +66,15 @@ VToolRecord &VToolRecord::operator=(const VToolRecord &record)
VToolRecord::VToolRecord(const VToolRecord &record) VToolRecord::VToolRecord(const VToolRecord &record)
:id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw()) :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;
}

View File

@ -56,6 +56,8 @@ public:
QString getNameDraw() const; QString getNameDraw() const;
void setNameDraw(const QString &value); void setNameDraw(const QString &value);
bool IsMandatory() const;
private: private:
/** @brief id tool id. */ /** @brief id tool id. */
quint32 id; quint32 id;

View File

@ -286,7 +286,7 @@ QDomElement VPatternRecipe::Step(const VToolRecord &tool)
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history."); Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history.");
const QDomElement domElem = m_pattern->elementById(tool.getId()); 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())); throw VExceptionInvalidHistory(tr("Can't find element by id '%1'").arg(tool.getId()));
} }