@ -197,12 +197,13 @@ void Feed::handleDownloadFailed(const QString &url, const QString &error)
void Feed : : handleParsingFinished ( const RSS : : Private : : ParsingResult & result )
void Feed : : handleParsingFinished ( const RSS : : Private : : ParsingResult & result )
{
{
if ( ! result . error . isEmpty ( ) ) {
m_hasError = ! result . error . isEmpty ( ) ;
m_hasError = true ;
LogMsg ( tr ( " Failed to parse RSS feed at '%1'. Reason: %2 " ) . arg ( m_url , result . error )
// For some reason, the RSS feed may contain malformed XML data and it may not be
, Log : : WARNING ) ;
// successfully parsed by the XML parser. We are still trying to load as many articles
}
// as possible until we encounter corrupted data. So we can have some articles here
else {
// even in case of parsing error.
if ( ! m_hasError | | ! result . articles . isEmpty ( ) ) {
if ( title ( ) ! = result . title ) {
if ( title ( ) ! = result . title ) {
m_title = result . title ;
m_title = result . title ;
emit titleChanged ( this ) ;
emit titleChanged ( this ) ;
@ -211,7 +212,7 @@ void Feed::handleParsingFinished(const RSS::Private::ParsingResult &result)
m_lastBuildDate = result . lastBuildDate ;
m_lastBuildDate = result . lastBuildDate ;
int newArticlesCount = 0 ;
int newArticlesCount = 0 ;
foreach ( const QVariantHash & varHash , result . articles ) {
for ( const QVariantHash & varHash : result . articles ) {
try {
try {
auto article = new Article ( this , varHash ) ;
auto article = new Article ( this , varHash ) ;
if ( addArticle ( article ) )
if ( addArticle ( article ) )
@ -223,11 +224,15 @@ void Feed::handleParsingFinished(const RSS::Private::ParsingResult &result)
}
}
m_dirty = ( newArticlesCount > 0 ) ;
m_dirty = ( newArticlesCount > 0 ) ;
store ( ) ;
store ( ) ;
m_hasError = false ;
LogMsg ( tr ( " RSS feed at '%1' successfully updated. Added %2 new articles. " )
LogMsg ( tr ( " RSS feed at '%1' updated. Added %2 new articles. " )
. arg ( m_url ) . arg ( newArticlesCount ) ) ;
. arg ( m_url , QString : : number ( newArticlesCount ) ) ) ;
}
if ( m_hasError ) {
LogMsg ( tr ( " Failed to parse RSS feed at '%1'. Reason: %2 " ) . arg ( m_url , result . error )
, Log : : WARNING ) ;
}
}
m_isLoading = false ;
m_isLoading = false ;