This commit is contained in:
Martin Rotter 2016-09-01 07:20:46 +02:00
parent 6d48863b1f
commit ab01f6b91c
6 changed files with 44 additions and 23 deletions

View File

@ -1,3 +1,13 @@
3.3.5
—————
Added:
Changed:
▪ Made some tweaks regarding bug #41. Number of new messages is now determined in feed downloader working thread too.
Fixed:
3.3.4 3.3.4
————— —————

View File

@ -73,7 +73,7 @@ APP_LOW_NAME = "rssguard"
APP_LOW_H_NAME = ".rssguard" APP_LOW_H_NAME = ".rssguard"
APP_AUTHOR = "Martin Rotter" APP_AUTHOR = "Martin Rotter"
APP_COPYRIGHT = "(C) 2011-2016 $$APP_AUTHOR" APP_COPYRIGHT = "(C) 2011-2016 $$APP_AUTHOR"
APP_VERSION = "3.3.4" APP_VERSION = "3.3.5"
APP_LONG_NAME = "$$APP_NAME $$APP_VERSION" APP_LONG_NAME = "$$APP_NAME $$APP_VERSION"
APP_EMAIL = "rotter.martinos@gmail.com" APP_EMAIL = "rotter.martinos@gmail.com"
APP_URL = "https://github.com/martinrotter/rssguard" APP_URL = "https://github.com/martinrotter/rssguard"

View File

@ -106,11 +106,13 @@ void FeedDownloader::oneFeedUpdateFinished(const QList<Message> &messages) {
<< feed->id() << " in thread: \'" << feed->id() << " in thread: \'"
<< QThread::currentThreadId() << "\'."; << QThread::currentThreadId() << "\'.";
int updated_messages; int updated_messages = feed->updateMessages(messages);
/*
QMetaObject::invokeMethod(feed, "updateMessages", Qt::BlockingQueuedConnection, QMetaObject::invokeMethod(feed, "updateMessages", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(int, updated_messages), Q_RETURN_ARG(int, updated_messages),
Q_ARG(QList<Message>, messages)); Q_ARG(QList<Message>, messages));
*/
if (updated_messages > 0) { if (updated_messages > 0) {
m_results.appendUpdatedFeed(QPair<QString,int>(feed->title(), updated_messages)); m_results.appendUpdatedFeed(QPair<QString,int>(feed->title(), updated_messages));

View File

@ -38,7 +38,6 @@
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
const QString str = QString::fromLocal8Bit(argv[i]); const QString str = QString::fromLocal8Bit(argv[i]);

View File

@ -128,7 +128,10 @@ void Feed::setUrl(const QString &url) {
} }
void Feed::updateCounts(bool including_total_count) { void Feed::updateCounts(bool including_total_count) {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); bool is_main_thread = QThread::currentThread() == qApp->thread();
QSqlDatabase database = is_main_thread ?
qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings) :
qApp->database()->connection(QSL("feed_upd"), DatabaseFactory::FromSettings);
int account_id = getParentServiceRoot()->accountId(); int account_id = getParentServiceRoot()->accountId();
if (including_total_count) { if (including_total_count) {
@ -148,16 +151,18 @@ void Feed::run() {
} }
int Feed::updateMessages(const QList<Message> &messages) { int Feed::updateMessages(const QList<Message> &messages) {
qDebug().nospace() << "Updating messages in DB. Main thread: " << bool is_main_thread = QThread::currentThread() == qApp->thread();
(QThread::currentThread() == qApp->thread() ? "true." : "false.");
qDebug("Updating messages in DB. Main thread: '%s'.", qPrintable(is_main_thread ? "true." : "false."));
int custom_id = customId(); int custom_id = customId();
int account_id = getParentServiceRoot()->accountId(); int account_id = getParentServiceRoot()->accountId();
bool anything_updated = false; bool anything_updated = false;
bool ok; bool ok;
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlDatabase database = is_main_thread ?
int updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id, url(), qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings) :
&anything_updated, &ok); qApp->database()->connection(QSL("feed_upd"), DatabaseFactory::FromSettings);
int updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id, url(), &anything_updated, &ok);
if (ok) { if (ok) {
if (updated_messages > 0) { if (updated_messages > 0) {

View File

@ -23,6 +23,8 @@
#include "miscellaneous/databasequeries.h" #include "miscellaneous/databasequeries.h"
#include "services/abstract/serviceroot.h" #include "services/abstract/serviceroot.h"
#include <QThread>
RecycleBin::RecycleBin(RootItem *parent_item) : RootItem(parent_item), m_totalCount(0), RecycleBin::RecycleBin(RootItem *parent_item) : RootItem(parent_item), m_totalCount(0),
m_unreadCount(0), m_contextMenu(QList<QAction*>()) { m_unreadCount(0), m_contextMenu(QList<QAction*>()) {
@ -46,7 +48,10 @@ int RecycleBin::countOfAllMessages() const {
} }
void RecycleBin::updateCounts(bool update_total_count) { void RecycleBin::updateCounts(bool update_total_count) {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); bool is_main_thread = QThread::currentThread() == qApp->thread();
QSqlDatabase database = is_main_thread ?
qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings) :
qApp->database()->connection(QSL("feed_upd"), DatabaseFactory::FromSettings);
m_unreadCount = DatabaseQueries::getMessageCountsForBin(database, getParentServiceRoot()->accountId(), false); m_unreadCount = DatabaseQueries::getMessageCountsForBin(database, getParentServiceRoot()->accountId(), false);