From c3322cdc91f43a76e9312c8cb5bbeb5cf7888447 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 18 Dec 2010 18:42:31 +0000 Subject: [PATCH] Fixes possible crash in the RSS Downloader dialog (when having RSS folders) --- src/rss/automatedrssdownloader.cpp | 12 +++++++++++- src/rss/rssfolder.cpp | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rss/automatedrssdownloader.cpp b/src/rss/automatedrssdownloader.cpp index 64394f835..585bcce5e 100644 --- a/src/rss/automatedrssdownloader.cpp +++ b/src/rss/automatedrssdownloader.cpp @@ -131,10 +131,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; } } @@ -443,8 +449,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());