Fixed issue #464. Crash. Issue with modeling node objects.

(grafted from 291ce7d161d51618e7164f6f7addb929e27ee8ac)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-04-03 19:52:53 +03:00
parent 371c352efc
commit 297b32d5d9
2 changed files with 61 additions and 26 deletions

View File

@ -19,6 +19,7 @@
- [#385] Add 'Open Recent' option in Tape.exe, 'File' dropdown menu.
# Version 0.4.4
- [#464] Crash. Issue with modeling node objects.
- [#463] Wrong export to DXF format.
- Fixed issue with deleting detail nodes.
- [#458] Issue with segment of curve.

View File

@ -1274,7 +1274,16 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
PointsCommonAttributes(domElement, id, mx, my);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idObject );
QSharedPointer<VPointF> point;
try
{
point = data->GeometricObject<VPointF>(idObject);
}
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e);
return;// Just ignore
}
data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject,
Draw::Modeling));
VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
@ -2180,6 +2189,8 @@ void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &pa
quint32 idTool = 0;
SplinesCommonAttributes(domElement, id, idObject, idTool);
try
{
const auto obj = data->GetGObject(idObject);
if (obj->getType() == GOType::Spline)
{
@ -2195,6 +2206,12 @@ void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &pa
spl->setMode(Draw::Modeling);
data->UpdateGObject(id, spl);
}
}
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e);
return;// Just ignore
}
VNodeSpline::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
}
@ -2218,6 +2235,8 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document
quint32 idTool = 0;
SplinesCommonAttributes(domElement, id, idObject, idTool);
try
{
const auto obj = data->GetGObject(idObject);
if (obj->getType() == GOType::SplinePath)
{
@ -2233,6 +2252,12 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document
spl->setMode(Draw::Modeling);
data->UpdateGObject(id, spl);
}
}
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e);
return;// Just ignore
}
VNodeSplinePath::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
}
catch (const VExceptionBadId &e)
@ -2300,7 +2325,16 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse
ToolsCommonAttributes(domElement, id);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
VArc *arc = new VArc(*data->GeometricObject<VArc>(idObject));
VArc *arc = nullptr;
try
{
arc = new VArc(*data->GeometricObject<VArc>(idObject));
}
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e);
return;// Just ignore
}
arc->setIdObject(idObject);
arc->setMode(Draw::Modeling);
data->UpdateGObject(id, arc);