Json: Avoid using iterators from temporaries

Doing it can lead to unexpected behavior

Change-Id: If3f838cc5b5a381d7c33223adcf53051a43b7c3c
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
Eike Ziller
2017-10-19 13:27:31 +02:00
parent 558730ac24
commit 5dfd48331f

View File

@@ -258,13 +258,14 @@ void JsonSchema::enterNestedTypeSchema()
QStringList JsonSchema::properties(JsonObjectValue *v) const QStringList JsonSchema::properties(JsonObjectValue *v) const
{ {
typedef QHash<QString, JsonValue *>::ConstIterator MemberConstIterator; using Members = QHash<QString, JsonValue *>;
QStringList all; QStringList all;
if (JsonObjectValue *ov = getObjectValue(kProperties(), v)) { if (JsonObjectValue *ov = getObjectValue(kProperties(), v)) {
const MemberConstIterator cend = ov->members().constEnd(); const Members members = ov->members();
for (MemberConstIterator it = ov->members().constBegin(); it != cend; ++it) const Members::ConstIterator cend = members.constEnd();
for (Members::ConstIterator it = members.constBegin(); it != cend; ++it)
if (hasPropertySchema(it.key())) if (hasPropertySchema(it.key()))
all.append(it.key()); all.append(it.key());
} }