Seam allowance tool already initializated and can't init the path.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-13 19:07:14 +02:00
parent 970762d0b3
commit af51e5e240

View File

@ -31,6 +31,7 @@
#include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecepath.h"
#include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecenode.h"
#include "../../undocommands/savepieceoptions.h" #include "../../undocommands/savepieceoptions.h"
#include "../vtoolseamallowance.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolPiecePath *VToolPiecePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VToolPiecePath *VToolPiecePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
@ -81,12 +82,24 @@ VToolPiecePath *VToolPiecePath::Create(quint32 _id, const VPiecePath &path, quin
pathTool->setParent(tool);// Adopted by a tool pathTool->setParent(tool);// Adopted by a tool
} }
else else
{
if (typeCreation == Source::FromGui && path.GetType() == PiecePathType::InternalPath)
{ // Seam allowance tool already initializated and can't init the path
SCASSERT(pieceId > NULL_ID);
VToolSeamAllowance *saTool = qobject_cast<VToolSeamAllowance*>(doc->getTool(pieceId));
SCASSERT(saTool != nullptr);
pathTool->setParentItem(saTool);
pathTool->SetParentType(ParentType::Item);
doc->IncrementReferens(id);
}
else
{ {
// Try to prevent memory leak // Try to prevent memory leak
scene->addItem(pathTool);// First adopted by scene scene->addItem(pathTool);// First adopted by scene
pathTool->hide();// If no one will use node, it will stay hidden pathTool->hide();// If no one will use node, it will stay hidden
pathTool->SetParentType(ParentType::Scene); pathTool->SetParentType(ParentType::Scene);
} }
}
return pathTool; return pathTool;
} }
return nullptr; return nullptr;