Fixed issue #405. Crash after deleting first pattern piece in the list.
--HG-- branch : release
This commit is contained in:
parent
9313eefd9e
commit
037ad21553
|
@ -1,3 +1,6 @@
|
||||||
|
# Version 0.4.3
|
||||||
|
- [#405] Fixed crash after deleting first pattern piece in the list.
|
||||||
|
|
||||||
# Version 0.4.2 February 17, 2016
|
# Version 0.4.2 February 17, 2016
|
||||||
- Measurement Diagram is not shown on Mac OS X.
|
- Measurement Diagram is not shown on Mac OS X.
|
||||||
- In dialog 'tool Spline Path' fixed broken selecting new point into the list of points.
|
- In dialog 'tool Spline Path' fixed broken selecting new point into the list of points.
|
||||||
|
|
|
@ -36,10 +36,13 @@ DeletePatternPiece::DeletePatternPiece(VAbstractPattern *doc, const QString &nam
|
||||||
{
|
{
|
||||||
setText(tr("delete pattern piece %1").arg(namePP));
|
setText(tr("delete pattern piece %1").arg(namePP));
|
||||||
|
|
||||||
QDomElement patternP = doc->GetPPElement(namePP);
|
const QDomElement patternP = doc->GetPPElement(namePP);
|
||||||
patternPiece = patternP.cloneNode().toElement();
|
patternPiece = patternP.cloneNode().toElement();
|
||||||
QDomNode previousPP = patternP.previousSibling();//find previous pattern piece
|
const QDomElement previousPP = patternP.previousSibling().toElement();//find previous pattern piece
|
||||||
previousPPName = doc->GetParametrString(previousPP.toElement(), VAbstractPattern::AttrName, "");
|
if (not previousPP.isNull() && previousPP.tagName() == VAbstractPattern::TagDraw)
|
||||||
|
{
|
||||||
|
previousPPName = doc->GetParametrString(previousPP, VAbstractPattern::AttrName, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -52,11 +55,28 @@ void DeletePatternPiece::undo()
|
||||||
qCDebug(vUndo, "Undo.");
|
qCDebug(vUndo, "Undo.");
|
||||||
|
|
||||||
QDomElement rootElement = doc->documentElement();
|
QDomElement rootElement = doc->documentElement();
|
||||||
QDomNode previousPP = doc->GetPPElement(previousPPName);
|
|
||||||
|
if (not previousPPName.isEmpty())
|
||||||
|
{ // not first in the list, add after tag draw
|
||||||
|
const QDomNode previousPP = doc->GetPPElement(previousPPName);
|
||||||
rootElement.insertAfter(patternPiece, previousPP);
|
rootElement.insertAfter(patternPiece, previousPP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // first in the list, add after tag increments
|
||||||
|
const QDomNodeList list = rootElement.elementsByTagName(VAbstractPattern::TagIncrements);
|
||||||
|
QDomElement increment;
|
||||||
|
|
||||||
|
if (not list.isEmpty())
|
||||||
|
{
|
||||||
|
increment = list.at(0).toElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT_X(not increment.isNull(), Q_FUNC_INFO, "Couldn't' find tag Increments");
|
||||||
|
rootElement.insertAfter(patternPiece, increment);
|
||||||
|
}
|
||||||
|
|
||||||
emit NeedFullParsing();
|
emit NeedFullParsing();
|
||||||
doc->ChangedActivPP(namePP);
|
doc->ChangeActivPP(namePP);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -65,7 +85,7 @@ void DeletePatternPiece::redo()
|
||||||
qCDebug(vUndo, "Redo.");
|
qCDebug(vUndo, "Redo.");
|
||||||
|
|
||||||
QDomElement rootElement = doc->documentElement();
|
QDomElement rootElement = doc->documentElement();
|
||||||
QDomElement patternPiece = doc->GetPPElement(namePP);
|
const QDomElement patternPiece = doc->GetPPElement(namePP);
|
||||||
rootElement.removeChild(patternPiece);
|
rootElement.removeChild(patternPiece);
|
||||||
emit NeedFullParsing();
|
emit NeedFullParsing();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user