From e11545c8a384a364aee0c564fb94659d1af43120 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 13 Nov 2010 20:14:59 +0000 Subject: [PATCH] Fix crash when hiding RSS and then showing it again --- src/GUI.cpp | 2 +- src/qtlibtorrent/qbtsession.cpp | 4 +++- src/rss/rss_imp.cpp | 6 +++--- src/rss/rss_imp.h | 4 +--- src/rss/rssmanager.cpp | 4 +++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 7aaa6c719..548104e47 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -364,7 +364,7 @@ void GUI::displayRSSTab(bool enable) { if(enable) { // RSS tab if(!rssWidget) { - rssWidget = new RSSImp(BTSession); + rssWidget = new RSSImp(tabs); int index_tab = tabs->addTab(rssWidget, tr("RSS")); tabs->setTabIcon(index_tab, QIcon(QString::fromUtf8(":/Icons/rss32.png"))); } diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index a03767b83..b7ab9b246 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -2641,6 +2641,8 @@ QBtSession * QBtSession::instance() void QBtSession::drop() { - if(m_instance) + if(m_instance) { delete m_instance; + m_instance = 0; + } } diff --git a/src/rss/rss_imp.cpp b/src/rss/rss_imp.cpp index 43871cc7c..970e02237 100644 --- a/src/rss/rss_imp.cpp +++ b/src/rss/rss_imp.cpp @@ -307,9 +307,9 @@ void RSSImp::downloadTorrent() { foreach(const QTreeWidgetItem* item, selected_items) { RssArticle* article = listStreams->getRSSItemFromUrl(item->text(NEWS_URL_COL))->getItem(item->text(NEWS_ID)); if(article->has_attachment()) { - BTSession->downloadFromUrl(article->getTorrentUrl()); + QBtSession::instance()->downloadFromUrl(article->getTorrentUrl()); } else { - BTSession->downloadFromUrl(article->getLink()); + QBtSession::instance()->downloadFromUrl(article->getLink()); } } } @@ -577,7 +577,7 @@ void RSSImp::updateRefreshInterval(unsigned int val) { rssmanager->updateRefreshInterval(val); } -RSSImp::RSSImp(QBtSession *BTSession) : QWidget(), BTSession(BTSession){ +RSSImp::RSSImp(QWidget *parent) : QWidget(parent) { setupUi(this); rssmanager = RssManager::instance(); diff --git a/src/rss/rss_imp.h b/src/rss/rss_imp.h index 0147883e6..e0b21d13d 100644 --- a/src/rss/rss_imp.h +++ b/src/rss/rss_imp.h @@ -36,7 +36,6 @@ #include "ui_rss.h" -class QBtSession; class FeedListWidget; class QTreeWidgetItem; class RssFolder; @@ -46,7 +45,7 @@ class RSSImp : public QWidget, public Ui::RSS{ Q_OBJECT public: - RSSImp(QBtSession *BTSession); + RSSImp(QWidget *parent); ~RSSImp(); public slots: @@ -85,7 +84,6 @@ private slots: private: RssManager *rssmanager; - QBtSession *BTSession; FeedListWidget *listStreams; QTreeWidgetItem* previous_news; diff --git a/src/rss/rssmanager.cpp b/src/rss/rssmanager.cpp index 647b4038a..71a9df356 100644 --- a/src/rss/rssmanager.cpp +++ b/src/rss/rssmanager.cpp @@ -149,6 +149,8 @@ RssManager * RssManager::instance() void RssManager::drop() { - if(m_instance) + if(m_instance) { delete m_instance; + m_instance = 0; + } }