Fixed issue #905. Valentina crashes with error: This id is not unique.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2018-11-28 12:00:40 +02:00
parent 6b93b77247
commit b970f056d9
8 changed files with 37 additions and 1 deletions

View File

@ -1,5 +1,6 @@
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.
- [#905] Valentina crashes with error: This id is not unique.
# Version 0.6.1 October 23, 2018
- [#885] Regression. Broken support for multi size measurements.

View File

@ -272,6 +272,11 @@ bool VDomDocument::find(QHash<quint32, QDomElement> &cache, const QDomElement &n
{
const quint32 elementId = GetParametrUInt(node, AttrId, NULL_ID_STR);
if (cache.contains(elementId))
{
qWarning() << tr("Not unique id (%1)").arg(elementId);
}
cache.insert(elementId, node);
if (elementId == id)
{
@ -596,7 +601,7 @@ void VDomDocument::CollectId(const QDomElement &node, QVector<quint32> &vector)
const quint32 id = GetParametrId(node);
if (vector.contains(id))
{
throw VExceptionWrongId(QString("This id (%1) is not unique.").arg(id), node);
throw VExceptionWrongId(tr("This id (%1) is not unique.").arg(id), node);
}
vector.append(id);
}

View File

@ -40,6 +40,7 @@
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vdomdocument.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexceptionwrongid.h"
#include "../../undocommands/addtocalc.h"
#include "../../undocommands/savetooloptions.h"
#include "../qmuparser/qmuparsererror.h"
@ -229,6 +230,12 @@ void VDrawTool::ChangeLabelVisibility(quint32 id, bool visible)
*/
void VDrawTool::AddToCalculation(const QDomElement &domElement)
{
const QDomElement duplicate = doc->elementById(m_id);
if (not duplicate.isNull())
{
throw VExceptionWrongId(tr("This id (%1) is not unique.").arg(m_id), duplicate);
}
AddToCalc *addToCal = new AddToCalc(domElement, doc);
connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
qApp->getUndoStack()->push(addToCal);

View File

@ -37,6 +37,7 @@
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexceptionwrongid.h"
#include "../vgeometry/vgobject.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/def.h"
@ -175,6 +176,12 @@ void VAbstractNode::ToolCreation(const Source &typeCreation)
*/
void VAbstractNode::AddToModeling(const QDomElement &domElement)
{
const QDomElement duplicate = doc->elementById(m_id);
if (not duplicate.isNull())
{
throw VExceptionWrongId(tr("This id (%1) is not unique.").arg(m_id), duplicate);
}
QDomElement modeling;
if (m_drawName.isEmpty())
{

View File

@ -69,6 +69,7 @@ VToolPin *VToolPin::Create(VToolPinInitData initData)
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e)
initData.data->UpdateId(initData.id);
return nullptr;// Just ignore
}
VPointF *pinPoint = new VPointF(*point);

View File

@ -97,6 +97,7 @@ VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData)
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e)
initData.data->UpdateId(initData.id);
return nullptr;// Just ignore
}
node->setName(point->name());

View File

@ -44,6 +44,7 @@
#include "../vgeometry/vsplinepath.h"
#include "../vgeometry/vplacelabelitem.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../ifc/exception/vexceptionwrongid.h"
#include "../undocommands/addpiece.h"
#include "../undocommands/deletepiece.h"
#include "../undocommands/movepiece.h"
@ -962,6 +963,12 @@ void VToolSeamAllowance::FullUpdateFromGuiApply()
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::AddToFile()
{
const QDomElement duplicate = doc->elementById(m_id);
if (not duplicate.isNull())
{
throw VExceptionWrongId(tr("This id (%1) is not unique.").arg(m_id), duplicate);
}
const VPiece piece = VAbstractTool::data.GetPiece(m_id);
QDomElement domElement = doc->createElement(getTagName());

View File

@ -45,6 +45,7 @@
#include "../ifc/xml/vabstractconverter.h"
#include "../ifc/xml/vdomdocument.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../ifc/exception/vexceptionwrongid.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vsplinepath.h"
@ -1835,6 +1836,12 @@ void VToolUnionDetails::AddDetail(QDomElement &domElement, const VPiece &d) cons
*/
void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
{
const QDomElement duplicate = doc->elementById(m_id);
if (not duplicate.isNull())
{
throw VExceptionWrongId(tr("This id (%1) is not unique.").arg(m_id), duplicate);
}
const QString drawName = DrawName(doc, d1id, d2id);
SCASSERT(not drawName.isEmpty())