From b92c152d309f189d0c74fbf9dda31b863376d4ad Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 18 Dec 2010 18:54:27 +0000 Subject: [PATCH] Fixes possible crash in the RSS Downloader dialog (when having RSS folders) --- Changelog | 1 + src/rss/automatedrssdownloader.cpp | 12 +++++++++++- src/rss/rssfolder.cpp | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index d28e25067..4880a85b2 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ - BUGFIX: Fix some 'File Not found' warning in the Web UI - BUGFIX: Fix dangerous usage of vector iterator - BUGFIX: No longer expand the first folder in the torrent content list + - BUGFIX: Fixes possible crash in the RSS Downloader dialog (closes #691426) * Sun Dec 5 2010 - Christophe Dumez - v2.5.1 - BUGFIX: Fix possible crash when right-clicking on a torrent diff --git a/src/rss/automatedrssdownloader.cpp b/src/rss/automatedrssdownloader.cpp index 4ae18d468..78b5d9c3d 100644 --- a/src/rss/automatedrssdownloader.cpp +++ b/src/rss/automatedrssdownloader.cpp @@ -126,10 +126,16 @@ void AutomatedRssDownloader::loadFeedList() const RssSettings settings; const QStringList feed_aliases = settings.getRssFeedsAliases(); const QStringList feed_urls = settings.getRssFeedsUrls(); + QStringList existing_urls; for(int i=0; ilistFeeds); - item->setData(Qt::UserRole, feed_urls.at(i)); + item->setData(Qt::UserRole, feed_url); item->setFlags(item->flags()|Qt::ItemIsUserCheckable); + existing_urls << feed_url; } } @@ -438,8 +444,12 @@ void AutomatedRssDownloader::updateMatchingArticles() RssDownloadRule rule = m_ruleList->getRule(rule_item->text()); if(!rule.isValid()) continue; foreach(const QString &feed_url, rule.rssFeeds()) { + qDebug() << Q_FUNC_INFO << feed_url; Q_ASSERT(all_feeds.contains(feed_url)); + if(!all_feeds.contains(feed_url)) continue; const RssFeed *feed = all_feeds.value(feed_url); + Q_ASSERT(feed); + if(!feed) continue; const QStringList matching_articles = rule.findMatchingArticles(feed); if(!matching_articles.isEmpty()) addFeedArticlesToTree(feed, matching_articles); diff --git a/src/rss/rssfolder.cpp b/src/rss/rssfolder.cpp index 4d86bee4b..6ab07d64d 100644 --- a/src/rss/rssfolder.cpp +++ b/src/rss/rssfolder.cpp @@ -268,7 +268,9 @@ QHash RssFolder::getAllFeedsAsHash() const { QHash ret; foreach(RssFile *item, this->values()) { if(item->getType() == RssFile::FEED) { - RssFeed* feed = static_cast(item); + RssFeed* feed = dynamic_cast(item); + Q_ASSERT(feed); + qDebug() << Q_FUNC_INFO << feed->getUrl(); ret[feed->getUrl()] = feed; } else { ret.unite(static_cast(item)->getAllFeedsAsHash());