From e533a16fe13e62aecab3ad245c43b671c0331c14 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 26 Jan 2016 07:28:32 +0100 Subject: [PATCH] Fixed #153. --- resources/text/CHANGELOG | 1 + src/gui/messagesview.cpp | 2 - src/services/standard/standardserviceroot.cpp | 39 ++++++++++++++----- src/services/tt-rss/ttrssserviceroot.cpp | 22 ++++++++--- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index e1ebff88c..a0e93f440 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -11,6 +11,7 @@ Added: ▪ User is now able to delete TT-RSS feeds. (issue #151) Fixed: +▪ Fixed problems with master update mutex locking. (bug #153) ▪ Fixed some problems, that "Add category to selected account" was enabled when it shouldn't be. ▪ ♥ Auto-updating of feeds fixed (again?!). ♥ ▪ Fixed problem with adding feeds in TT-RSS accounts. (bug #154) diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index b67327eb0..4d42f6a1e 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -100,8 +100,6 @@ void MessagesView::reloadSelections(bool mark_current_index_read) { else { // Messages were probably removed from the model, nothing can // be selected and no message can be displayed. - // TOTO: Check if this is OKAY. If not, then emit this signal - // from FeedsView itself. emit currentMessagesRemoved(); } } diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 7baaee798..85ff0fb0e 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -133,9 +132,21 @@ bool StandardServiceRoot::supportsCategoryAdding() const { } void StandardServiceRoot::addNewFeed(const QString &url) { - QPointer form_pointer = new FormStandardFeedDetails(this, qApp->mainForm()); + if (!qApp->feedUpdateLock()->tryLock()) { + // Lock was not obtained because + // it is used probably by feed updater or application + // is quitting. + qApp->showGuiMessage(tr("Cannot add item"), + tr("Cannot add feed because another critical operation is ongoing."), + QSystemTrayIcon::Warning, qApp->mainForm(), true); + // Thus, cannot delete and quit the method. + return; + } + + QScopedPointer form_pointer(new FormStandardFeedDetails(this, qApp->mainForm())); form_pointer.data()->exec(NULL, NULL, url); - delete form_pointer.data(); + + qApp->feedUpdateLock()->unlock(); } QVariant StandardServiceRoot::data(int column, int role) const { @@ -405,23 +416,33 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model, } void StandardServiceRoot::addNewCategory() { - QPointer form_pointer = new FormStandardCategoryDetails(this, qApp->mainForm()); + if (!qApp->feedUpdateLock()->tryLock()) { + // Lock was not obtained because + // it is used probably by feed updater or application + // is quitting. + qApp->showGuiMessage(tr("Cannot add category"), + tr("Cannot add category because another critical operation is ongoing."), + QSystemTrayIcon::Warning, qApp->mainForm(), true); + // Thus, cannot delete and quit the method. + return; + } + + QScopedPointer form_pointer(new FormStandardCategoryDetails(this, qApp->mainForm())); form_pointer.data()->exec(NULL, NULL); - delete form_pointer.data(); + + qApp->feedUpdateLock()->unlock(); } void StandardServiceRoot::importFeeds() { - QPointer form = new FormStandardImportExport(this, qApp->mainForm()); + QScopedPointer form(new FormStandardImportExport(this, qApp->mainForm())); form.data()->setMode(FeedsImportExportModel::Import); form.data()->exec(); - delete form.data(); } void StandardServiceRoot::exportFeeds() { - QPointer form = new FormStandardImportExport(this, qApp->mainForm()); + QScopedPointer form(new FormStandardImportExport(this, qApp->mainForm())); form.data()->setMode(FeedsImportExportModel::Export); form.data()->exec(); - delete form.data(); } QStringList StandardServiceRoot::textualFeedIds(const QList &feeds) { diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index 20a09469e..1c6d5bdd7 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -19,6 +19,7 @@ #include "miscellaneous/application.h" #include "miscellaneous/settings.h" +#include "miscellaneous/mutex.h" #include "miscellaneous/textfactory.h" #include "gui/dialogs/formmain.h" #include "network-web/networkfactory.h" @@ -34,7 +35,6 @@ #include #include #include -#include #include #include @@ -62,7 +62,6 @@ void TtRssServiceRoot::start(bool freshly_activated) { void TtRssServiceRoot::stop() { m_network->logout(); - qDebug("Stopping Tiny Tiny RSS account, logging out with result '%d'.", (int) m_network->lastError()); } @@ -71,9 +70,9 @@ QString TtRssServiceRoot::code() const { } bool TtRssServiceRoot::editViaGui() { - QPointer form_pointer = new FormEditAccount(qApp->mainForm()); + QScopedPointer form_pointer(new FormEditAccount(qApp->mainForm())); form_pointer.data()->execForEdit(this); - delete form_pointer.data(); + return false; } @@ -119,10 +118,21 @@ bool TtRssServiceRoot::supportsCategoryAdding() const { } void TtRssServiceRoot::addNewFeed(const QString &url) { - QPointer form_pointer = new FormEditFeed(this, qApp->mainForm()); + if (!qApp->feedUpdateLock()->tryLock()) { + // Lock was not obtained because + // it is used probably by feed updater or application + // is quitting. + qApp->showGuiMessage(tr("Cannot add item"), + tr("Cannot add feed because another critical operation is ongoing."), + QSystemTrayIcon::Warning, qApp->mainForm(), true); + // Thus, cannot delete and quit the method. + return; + } + QScopedPointer form_pointer(new FormEditFeed(this, qApp->mainForm())); form_pointer.data()->execForAdd(url); - delete form_pointer.data(); + + qApp->feedUpdateLock()->unlock(); } void TtRssServiceRoot::addNewCategory() {