Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
4.8.1
-
None
-
Kubuntu 12.04
-
ccd8a496c (dev), 3e2be095e (6.5), ce3ca69dc (6.6), a9fe8dde7 (tqtc/lts-6.2)
Description
Hi all,
I was just debugging a piece of code similar to the attached, and was a little surprised by the behaviour of readNextStartElement(). It seems that if we use readNextStartElement() repeatedly to parse a well-formed XML document, then calling readNextStartElement() after we've read the whole of the XML document sets the error status to QXmlStreamReader::PrematureEndOfDocumentError. This is odd, as the documentation for this error code says:
"The input stream ended before a well-formed XML document was parsed."
which, if my understanding of XML + QXmlStreamReader is correct, is untrue in this case!
I personally think the following behaviour would be more logical: if we attempt to readNextStartElement() after we've already read the entirety of a well-formed XML document, then
a) readNextStartElement() should return false;
b) it should not set the error flag for the QXmlStreamReader i.e. hasError() should return false; and
c) tokenType() should be QXmlStreamReader::EndDocument.
This would get rid of the incorrect statement that we didn't manage to read a well-formed XML document, and makes the attached program work.
What do you guys reckon?
Attachments
For Gerrit Dashboard: QTBUG-25944 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
495710,2 | QXmlStreamReader::readNextStartElement() - return false on document end | dev | qt/qtbase | Status: MERGED | +2 | 0 |
496528,2 | QXmlStreamReader::readNextStartElement() - return false on document end | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |
496529,2 | QXmlStreamReader::readNextStartElement() - return false on document end | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
496585,2 | QXmlStreamReader::readNextStartElement() - return false on document end | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |