From af51e5e24027b2684a11cd0376a80a480984b276 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 13 Jan 2017 19:07:14 +0200 Subject: [PATCH] Seam allowance tool already initializated and can't init the path. --HG-- branch : feature --- .../tools/nodeDetails/vtoolpiecepath.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp index 54fc53749..e86ff9d1c 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp @@ -31,6 +31,7 @@ #include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecenode.h" #include "../../undocommands/savepieceoptions.h" +#include "../vtoolseamallowance.h" //--------------------------------------------------------------------------------------------------------------------- VToolPiecePath *VToolPiecePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -82,10 +83,22 @@ VToolPiecePath *VToolPiecePath::Create(quint32 _id, const VPiecePath &path, quin } else { - // Try to prevent memory leak - scene->addItem(pathTool);// First adopted by scene - pathTool->hide();// If no one will use node, it will stay hidden - pathTool->SetParentType(ParentType::Scene); + 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(doc->getTool(pieceId)); + SCASSERT(saTool != nullptr); + pathTool->setParentItem(saTool); + pathTool->SetParentType(ParentType::Item); + doc->IncrementReferens(id); + } + else + { + // Try to prevent memory leak + scene->addItem(pathTool);// First adopted by scene + pathTool->hide();// If no one will use node, it will stay hidden + pathTool->SetParentType(ParentType::Scene); + } } return pathTool; }