From 0f226d6cdfb06db52f54799ef6ebd94bab557da1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 27 Mar 2019 09:46:33 +0200 Subject: [PATCH] Fix wrong use of SetAttributeOrRemoveIf(). The remove condition must be calculated not hardcoded. --HG-- branch : develop --- src/app/valentina/xml/vpattern.cpp | 6 +++--- src/libs/vtools/tools/vabstracttool.cpp | 8 +++++--- src/libs/vtools/tools/vtoolseamallowance.cpp | 3 ++- src/libs/vtools/undocommands/togglepiecestate.cpp | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index af207b042..c627a2400 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -4227,7 +4227,7 @@ void VPattern::SetDefCustomHeight(int value) QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - SetAttributeOrRemoveIf(domElement, AttrDefHeight, value, 0); + SetAttributeOrRemoveIf(domElement, AttrDefHeight, value, value == 0); modified = true; } else @@ -4279,7 +4279,7 @@ void VPattern::SetDefCustomSize(int value) QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - SetAttributeOrRemoveIf(domElement, AttrDefSize, value, 0); + SetAttributeOrRemoveIf(domElement, AttrDefSize, value, value == 0); modified = true; } else @@ -4308,7 +4308,7 @@ void VPattern::SetReadOnly(bool rOnly) if (not pattern.isNull()) { - SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, false); + SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, not rOnly); modified = true; } } diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 0fa15a6be..fa0fc7f6a 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -523,8 +523,9 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa } } - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), false); - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), true); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), not node.IsExcluded()); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), + node.IsCheckUniqueness()); switch (type) { @@ -581,7 +582,8 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle); } - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), true); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), + node.IsShowSecondPassmark()); return nod; } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 4fbb23cd5..c9da4dd7d 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -276,7 +276,8 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping()); doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance()); doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath()); - doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), false); + doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), + not piece.IsSeamAllowanceBuiltIn()); doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth()); doc->SetAttribute(domElement, AttrUnited, piece.IsUnited()); } diff --git a/src/libs/vtools/undocommands/togglepiecestate.cpp b/src/libs/vtools/undocommands/togglepiecestate.cpp index d7febff87..5e22bd383 100644 --- a/src/libs/vtools/undocommands/togglepiecestate.cpp +++ b/src/libs/vtools/undocommands/togglepiecestate.cpp @@ -75,7 +75,7 @@ void TogglePieceInLayout::Do(bool state) QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail); if (detail.isElement()) { - doc->SetAttributeOrRemoveIf(detail, AttrInLayout, state, true); + doc->SetAttributeOrRemoveIf(detail, AttrInLayout, state, state); VPiece det = m_data->DataPieces()->value(m_id); det.SetInLayout(state);