diff --git a/src/rss/rssfeed.cpp b/src/rss/rssfeed.cpp index 2b92c3bfa..07a485eae 100644 --- a/src/rss/rssfeed.cpp +++ b/src/rss/rssfeed.cpp @@ -125,6 +125,7 @@ void RssFeed::addArticle(const RssArticlePtr& article) // Insertion sort RssArticleList::Iterator lowerBound = qLowerBound(m_articlesByDate.begin(), m_articlesByDate.end(), article, rssArticleDateRecentThan); m_articlesByDate.insert(lowerBound, article); + const int lbIndex = m_articlesByDate.indexOf(article); // Restrict size const int max_articles = RssSettings().getRSSMaxArticlesPerFeed(); if (m_articlesByDate.size() > max_articles) { @@ -134,6 +135,12 @@ void RssFeed::addArticle(const RssArticlePtr& article) if (!oldestArticle->isRead()) --m_unreadCount; } + + // Check if article was inserted at the end of the list and will break max_articles limit + if (RssSettings().isRssDownloadingEnabled()) { + if (lbIndex < max_articles && !article->isRead()) + downloadArticleTorrentIfMatching(m_manager->downloadRules(), article); + } } QList RssFeed::feedCookies() const @@ -367,10 +374,6 @@ void RssFeed::handleNewArticle(const QString& feedUrl, const QVariantHash& artic Q_ASSERT(article); addArticle(article); - // Download torrent if necessary. - if (RssSettings().isRssDownloadingEnabled()) - downloadArticleTorrentIfMatching(m_manager->downloadRules(), article); - m_manager->forwardFeedInfosChanged(m_url, displayName(), m_unreadCount); // FIXME: We should forward the information here but this would seriously decrease // performance with current design.