From fa070b56ab01dea7e6510fdee09dfc877f32275f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 9 Jan 2020 19:04:52 +0200 Subject: [PATCH] Cppcheck warning. --HG-- branch : develop --- src/libs/ifc/xml/vdomdocument.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index fb5fb5efd..25dbb379c 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -173,11 +173,9 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) return attributes1.size() < attributes2.size(); } - bool stop = false; - - auto CompareDomNodeLists = [&stop](QList list1, QList list2) + auto CompareDomNodeLists = [](QList list1, QList list2, bool *stop) { - stop = false; + *stop = false; std::sort(list1.begin(), list1.end(), LessThen); std::sort(list2.begin(), list2.end(), LessThen); //qDebug() << "comparing sorted lists"; @@ -187,14 +185,14 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) { if (LessThen(list2[k], list1[k])) { - stop = true; + *stop = true; //qDebug() << "false!"; return false; } } else { - stop = true; + *stop = true; //qDebug() << "true!"; return true; } @@ -202,7 +200,8 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) return false; }; - bool result = CompareDomNodeLists(attributes1, attributes2); + bool stop = false; + bool result = CompareDomNodeLists(attributes1, attributes2, &stop); if (stop) { return result; @@ -228,8 +227,7 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) return value1 < value2; } - result = CompareDomNodeLists(elts1, elts2); - // cppcheck-suppress identicalConditionAfterEarlyExit + result = CompareDomNodeLists(elts1, elts2, &stop); if (stop) { return result;