rsslisting example: fix bug in construction of title string
The correct time to clear titleString and linkString is at the start of the item element, to avoid not only the left-overs from a previous item but also any stray titles and links that don't belong to any item. The channel element, that contains the items, may also have title and link elements. This, indeed, lead to the first entry in the displayed table having a "Qt Blog" prefix on its blog-post's title. Fortunately the link was already being set, usually to empty, due to the lack of rss:about attributes on item elements. Task-number: QTBUG-111228 Change-Id: I16647e2498b58caaafa6e88ef73f0d934a1f8396 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 637e1542cfd75969edabba547af693f29411e6aa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9f3cde89c9
commit
457dc2c47b
@ -163,8 +163,10 @@ void RSSListing::parseXml()
|
||||
while (!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
if (xml.isStartElement()) {
|
||||
if (xml.name() == u"item")
|
||||
if (xml.name() == u"item") {
|
||||
linkString = xml.attributes().value("rss:about").toString();
|
||||
titleString.clear();
|
||||
}
|
||||
currentTag = xml.name().toString();
|
||||
} else if (xml.isEndElement()) {
|
||||
if (xml.name() == u"item") {
|
||||
@ -173,9 +175,6 @@ void RSSListing::parseXml()
|
||||
item->setText(0, titleString);
|
||||
item->setText(1, linkString);
|
||||
treeWidget->addTopLevelItem(item);
|
||||
|
||||
titleString.clear();
|
||||
linkString.clear();
|
||||
}
|
||||
|
||||
} else if (xml.isCharacters() && !xml.isWhitespace()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user