diff --git a/src/core/systemfactory.cpp b/src/core/systemfactory.cpp index 17fdb216f..96b34438a 100644 --- a/src/core/systemfactory.cpp +++ b/src/core/systemfactory.cpp @@ -11,13 +11,12 @@ #include #include #include -#include QPointer SystemFactory::s_instance; SystemFactory::SystemFactory(QObject *parent) : QObject(parent) { - m_applicationCloseLock = new QReadWriteLock(QReadWriteLock::NonRecursive); + m_applicationCloseLock = new QMutex(); } SystemFactory::~SystemFactory() { diff --git a/src/core/systemfactory.h b/src/core/systemfactory.h index 8595a0b4d..00e134f7e 100644 --- a/src/core/systemfactory.h +++ b/src/core/systemfactory.h @@ -3,11 +3,9 @@ #include #include +#include -class QReadWriteLock; -class QMutex; - class SystemFactory : public QObject { Q_OBJECT @@ -42,7 +40,7 @@ class SystemFactory : public QObject { // Access to application-wide close lock. - inline QReadWriteLock *applicationCloseLock() const { + inline QMutex *applicationCloseLock() const { return m_applicationCloseLock; } @@ -62,7 +60,7 @@ class SystemFactory : public QObject { // But of user decides to close the application (in other words, // tries to lock the lock for writing), then no other // action will be allowed to lock for reading. - QReadWriteLock *m_applicationCloseLock; + QMutex *m_applicationCloseLock; static QPointer s_instance; }; diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 406fdd242..186054358 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -99,7 +98,7 @@ void FeedMessageViewer::quitDownloader() { } void FeedMessageViewer::updateSelectedFeeds() { - if (SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + if (SystemFactory::instance()->applicationCloseLock()->tryLock()) { emit feedsUpdateRequested(m_feedsView->selectedFeeds()); } else { @@ -118,7 +117,7 @@ void FeedMessageViewer::updateSelectedFeeds() { } void FeedMessageViewer::updateAllFeeds() { - if (SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + if (SystemFactory::instance()->applicationCloseLock()->tryLock()) { emit feedsUpdateRequested(m_feedsView->allFeeds()); } else { diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 2a08d1e55..b8318bb20 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -76,7 +76,7 @@ void FeedsView::clearSelectedFeeds() { } void FeedsView::addNewStandardCategory() { - if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + if (!SystemFactory::instance()->applicationCloseLock()->tryLock()) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. @@ -115,7 +115,7 @@ void FeedsView::editStandardCategory(FeedsModelStandardCategory *category) { } void FeedsView::addNewStandardFeed() { - if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + if (!SystemFactory::instance()->applicationCloseLock()->tryLock()) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. @@ -154,7 +154,7 @@ void FeedsView::editStandardFeed(FeedsModelStandardFeed *feed) { } void FeedsView::editSelectedItem() { - if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + if (!SystemFactory::instance()->applicationCloseLock()->tryLock()) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. @@ -212,7 +212,7 @@ void FeedsView::editSelectedItem() { } void FeedsView::deleteSelectedItem() { - if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + if (!SystemFactory::instance()->applicationCloseLock()->tryLock()) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index d90ed51c0..86de5332c 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -175,7 +175,7 @@ void FormMain::onSaveState(QSessionManager &manager) { void FormMain::onAboutToQuit() { // Make sure that we obtain close lock // BEFORE even trying to quit the application. - if (SystemFactory::instance()->applicationCloseLock()->tryLockForWrite(CLOSE_LOCK_TIMEOUT)) { + if (SystemFactory::instance()->applicationCloseLock()->tryLock(CLOSE_LOCK_TIMEOUT)) { // Application obtained permission to close // in a safety way. qDebug("Close lock obtained safely.");