Cppcheck warning.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2020-01-09 19:04:52 +02:00
parent 078f6fad64
commit fa070b56ab

View File

@ -173,11 +173,9 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2)
return attributes1.size() < attributes2.size(); return attributes1.size() < attributes2.size();
} }
bool stop = false; auto CompareDomNodeLists = [](QList<QDomNode> list1, QList<QDomNode> list2, bool *stop)
auto CompareDomNodeLists = [&stop](QList<QDomNode> list1, QList<QDomNode> list2)
{ {
stop = false; *stop = false;
std::sort(list1.begin(), list1.end(), LessThen); std::sort(list1.begin(), list1.end(), LessThen);
std::sort(list2.begin(), list2.end(), LessThen); std::sort(list2.begin(), list2.end(), LessThen);
//qDebug() << "comparing sorted lists"; //qDebug() << "comparing sorted lists";
@ -187,14 +185,14 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2)
{ {
if (LessThen(list2[k], list1[k])) if (LessThen(list2[k], list1[k]))
{ {
stop = true; *stop = true;
//qDebug() << "false!"; //qDebug() << "false!";
return false; return false;
} }
} }
else else
{ {
stop = true; *stop = true;
//qDebug() << "true!"; //qDebug() << "true!";
return true; return true;
} }
@ -202,7 +200,8 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2)
return false; return false;
}; };
bool result = CompareDomNodeLists(attributes1, attributes2); bool stop = false;
bool result = CompareDomNodeLists(attributes1, attributes2, &stop);
if (stop) if (stop)
{ {
return result; return result;
@ -228,8 +227,7 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2)
return value1 < value2; return value1 < value2;
} }
result = CompareDomNodeLists(elts1, elts2); result = CompareDomNodeLists(elts1, elts2, &stop);
// cppcheck-suppress identicalConditionAfterEarlyExit
if (stop) if (stop)
{ {
return result; return result;