From d3acff747cce2b1432c146c722caeb2381993691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 22 Jan 2010 15:52:28 +0100 Subject: [PATCH] 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. --- src/plugins/qmljseditor/qmlcodecompletion.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljseditor/qmlcodecompletion.cpp b/src/plugins/qmljseditor/qmlcodecompletion.cpp index 005ea17cc36..8cce3c3c4d6 100644 --- a/src/plugins/qmljseditor/qmlcodecompletion.cpp +++ b/src/plugins/qmljseditor/qmlcodecompletion.cpp @@ -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(); }