From f1532fc5a56935f3160b5c9a373beca9140f3b71 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 23 Aug 2016 10:14:19 +0200 Subject: [PATCH] Fixed #41. --- resources/text/CHANGELOG | 1 + src/core/feeddownloader.cpp | 6 +++++- src/services/abstract/feed.cpp | 3 +++ src/services/abstract/feed.h | 7 ++++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 9e7dd3219..dd8341a18 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -9,6 +9,7 @@ Changed: Fixed: ▪ RSS Guard was not launchable in Windows XP. (bug #53) +▪ RSS Guard crashed when switching msg status during feed updates. (bug #41) 3.3.3 ————— diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index 91fac96a4..c6b9d3a95 100755 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -105,7 +105,11 @@ void FeedDownloader::oneFeedUpdateFinished(const QList &messages) { << QThread::currentThreadId() << "\'."; if (!m_stopUpdate) { - int updated_messages = messages.isEmpty() ? 0 : feed->updateMessages(messages); + int updated_messages; + + QMetaObject::invokeMethod(feed, "updateMessages", Qt::BlockingQueuedConnection, + Q_RETURN_ARG(int, updated_messages), + Q_ARG(QList, messages)); if (updated_messages > 0) { m_results.appendUpdatedFeed(QPair(feed->title(), updated_messages)); diff --git a/src/services/abstract/feed.cpp b/src/services/abstract/feed.cpp index 111f0cf1d..d637391a0 100755 --- a/src/services/abstract/feed.cpp +++ b/src/services/abstract/feed.cpp @@ -149,6 +149,9 @@ void Feed::run() { } int Feed::updateMessages(const QList &messages) { + qDebug().nospace() << "Updating messages in DB. Main thread: " << + (QThread::currentThread() == qApp->thread() ? "true." : "false."); + int custom_id = customId(); int account_id = getParentServiceRoot()->accountId(); bool anything_updated = false; diff --git a/src/services/abstract/feed.h b/src/services/abstract/feed.h index 4919ae687..af3ebf105 100755 --- a/src/services/abstract/feed.h +++ b/src/services/abstract/feed.h @@ -78,12 +78,13 @@ class Feed : public RootItem, public QRunnable { QString url() const; void setUrl(const QString &url); - int updateMessages(const QList &messages); - void updateCounts(bool including_total_count); - // Runs update in thread (thread pooled). void run(); + public slots: + void updateCounts(bool including_total_count); + int updateMessages(const QList &messages); + private: // Performs synchronous obtaining of new messages for this feed. virtual QList obtainNewMessages() = 0;