Commit d3acff74 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Don't try to read the next start element after the root element

There can only be one root element in an XML document, and when we try
to read another one we get a premature end of document error.
parent cfd99849
......@@ -895,7 +895,7 @@ void QmlCodeCompletion::updateSnippets()
QFile file(qmlsnippets);
file.open(QIODevice::ReadOnly);
QXmlStreamReader xml(&file);
while (!xml.atEnd() && xml.readNextStartElement()) {
if (xml.readNextStartElement()) {
if (xml.name() == QLatin1String("snippets")) {
while (xml.readNextStartElement()) {
if (xml.name() == QLatin1String("snippet")) {
......@@ -919,7 +919,6 @@ void QmlCodeCompletion::updateSnippets()
item.icon = icon;
m_snippets.append(item);
break;
}
if (xml.isCharacters())
......@@ -933,14 +932,17 @@ void QmlCodeCompletion::updateSnippets()
data += QChar::ObjectReplacementCharacter;
}
}
}
} else {
xml.skipCurrentElement();
}
}
} else {
xml.skipCurrentElement();
}
}
if (xml.hasError())
qWarning() << qmlsnippets << xml.errorString();
qWarning() << qmlsnippets << xml.errorString() << xml.lineNumber() << xml.columnNumber();
file.close();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment