GUI: Fix reading multiple error locations from XML.

This commit is contained in:
Kimmo Varis 2011-02-05 18:33:45 +02:00
parent c116caa7eb
commit dd0182c99d
2 changed files with 11 additions and 20 deletions

View File

@ -190,7 +190,9 @@ ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader)
*/ */
ErrorItem item; ErrorItem item;
if (reader->name().toString() == ErrorElementName)
// Read error element from inside errors element
if (mXmlReader->name() == ErrorElementName)
{ {
QXmlStreamAttributes attribs = reader->attributes(); QXmlStreamAttributes attribs = reader->attributes();
item.id = attribs.value("", IdAttribute).toString(); item.id = attribs.value("", IdAttribute).toString();
@ -199,23 +201,17 @@ ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader)
item.summary = XmlReport::unquoteMessage(summary); item.summary = XmlReport::unquoteMessage(summary);
const QString message = attribs.value("", VerboseAttribute).toString(); const QString message = attribs.value("", VerboseAttribute).toString();
item.message = XmlReport::unquoteMessage(message); item.message = XmlReport::unquoteMessage(message);
ReadLocations(item);
}
return item;
} }
void XmlReportV2::ReadLocations(ErrorItem &item) bool errorRead = false;
{ while (!errorRead && !mXmlReader->atEnd())
QList<ErrorItem> errors;
bool allRead = false;
while (!allRead && !mXmlReader->atEnd())
{ {
switch (mXmlReader->readNext()) switch (mXmlReader->readNext())
{ {
case QXmlStreamReader::StartElement: case QXmlStreamReader::StartElement:
if (mXmlReader->name() != LocationElementName)
continue; // Skip other than location elements // Read location element from inside error element
if (mXmlReader->name() == LocationElementName)
{ {
QXmlStreamAttributes attribs = mXmlReader->attributes(); QXmlStreamAttributes attribs = mXmlReader->attributes();
QString file = attribs.value("", FilenameAttribute).toString(); QString file = attribs.value("", FilenameAttribute).toString();
@ -229,8 +225,8 @@ void XmlReportV2::ReadLocations(ErrorItem &item)
break; break;
case QXmlStreamReader::EndElement: case QXmlStreamReader::EndElement:
if (mXmlReader->name() == LocationElementName) if (mXmlReader->name() == ErrorElementName)
allRead = true; errorRead = true;
break; break;
// Not handled // Not handled
@ -246,4 +242,5 @@ void XmlReportV2::ReadLocations(ErrorItem &item)
break; break;
} }
} }
return item;
} }

View File

@ -81,12 +81,6 @@ protected:
*/ */
ErrorItem ReadError(QXmlStreamReader *reader); ErrorItem ReadError(QXmlStreamReader *reader);
/**
* @brief Read and parse error items location elements from XML stream.
* @param item ErrorItem to write the location data.
*/
void ReadLocations(ErrorItem &item);
private: private:
/** /**
* @brief XML stream reader for reading the report in XML format. * @brief XML stream reader for reading the report in XML format.