QReadWriteLock replaced with QMutex.
This commit is contained in:
parent
f1229f9003
commit
1672198bee
@ -11,13 +11,12 @@
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QReadWriteLock>
|
||||
|
||||
|
||||
QPointer<SystemFactory> SystemFactory::s_instance;
|
||||
|
||||
SystemFactory::SystemFactory(QObject *parent) : QObject(parent) {
|
||||
m_applicationCloseLock = new QReadWriteLock(QReadWriteLock::NonRecursive);
|
||||
m_applicationCloseLock = new QMutex();
|
||||
}
|
||||
|
||||
SystemFactory::~SystemFactory() {
|
||||
|
@ -3,11 +3,9 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QMutex>
|
||||
|
||||
|
||||
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<SystemFactory> s_instance;
|
||||
};
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QMenu>
|
||||
#include <QWidgetAction>
|
||||
#include <QThread>
|
||||
#include <QReadWriteLock>
|
||||
#include <QProgressBar>
|
||||
#include <QStatusBar>
|
||||
|
||||
@ -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 {
|
||||
|
@ -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.
|
||||
|
@ -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.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user