diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index d781bd39e..d19681453 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -133,7 +133,7 @@ int FeedsModel::rowCount(const QModelIndex &parent) const { return parent_item->childCount(); } -bool FeedsModel::removeItem(const QModelIndex &index) { +bool FeedsModel::removeItem(const QModelIndex &index) { if (index.isValid()) { QModelIndex parent_index = index.parent(); FeedsModelRootItem *deleting_item = itemForIndex(index); diff --git a/src/core/systemfactory.cpp b/src/core/systemfactory.cpp index 41d2f1902..17fdb216f 100644 --- a/src/core/systemfactory.cpp +++ b/src/core/systemfactory.cpp @@ -94,7 +94,7 @@ QString SystemFactory::getAutostartDesktopFileLocation() { } #endif -SystemFactory *SystemFactory::getInstance() { +SystemFactory *SystemFactory::instance() { if (s_instance.isNull()) { s_instance = new SystemFactory(qApp); } diff --git a/src/core/systemfactory.h b/src/core/systemfactory.h index 9fb869576..8595a0b4d 100644 --- a/src/core/systemfactory.h +++ b/src/core/systemfactory.h @@ -47,7 +47,7 @@ class SystemFactory : public QObject { } // Singleton getter. - static SystemFactory *getInstance(); + static SystemFactory *instance(); private: // This read-write lock is used by application on its close. diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 52f05580b..bb87cd1f6 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -103,7 +103,7 @@ void FeedMessageViewer::quitDownloader() { } void FeedMessageViewer::updateSelectedFeeds() { - if (SystemFactory::getInstance()->applicationCloseLock()->tryLockForRead()) { + if (SystemFactory::instance()->applicationCloseLock()->tryLockForRead()) { emit feedsUpdateRequested(m_feedsView->selectedFeeds()); } else { @@ -112,7 +112,7 @@ void FeedMessageViewer::updateSelectedFeeds() { } void FeedMessageViewer::updateAllFeeds() { - if (SystemFactory::getInstance()->applicationCloseLock()->tryLockForRead()) { + if (SystemFactory::instance()->applicationCloseLock()->tryLockForRead()) { emit feedsUpdateRequested(m_feedsView->allFeeds()); } else { @@ -146,7 +146,7 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, void FeedMessageViewer::onFeedUpdatesFinished() { // Updates of some feeds finished, unlock the lock. - SystemFactory::getInstance()->applicationCloseLock()->unlock(); + SystemFactory::instance()->applicationCloseLock()->unlock(); FormMain::instance()->statusBar()->clearProgress(); } diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index af74752cc..9f285d0b2 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -1,6 +1,7 @@ #include "gui/feedsview.h" #include "core/defs.h" +#include "core/systemfactory.h" #include "core/feedsmodelfeed.h" #include "core/feedsmodel.h" #include "core/feedsproxymodel.h" @@ -9,12 +10,14 @@ #include "core/feedsmodelstandardcategory.h" #include "gui/formmain.h" #include "gui/formstandardcategorydetails.h" +#include "gui/systemtrayicon.h" #include #include #include #include #include +#include FeedsView::FeedsView(QWidget *parent) @@ -124,6 +127,23 @@ void FeedsView::editSelectedItem() { } void FeedsView::deleteSelectedItem() { + if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + // Lock was not obtained because + // it is used probably by feed updater or application + // is quitting. + if (SystemTrayIcon::isSystemTrayActivated()) { + SystemTrayIcon::instance()->showMessage(tr("Cannot delete item"), + tr("Selected item cannot be deleted because feed update is ongoing."), + QSystemTrayIcon::Warning); + } + else { + + } + + // Thus, cannot delete and quit the method. + return; + } + QModelIndex current_index = currentIndex(); QItemSelectionModel *selection_model = selectionModel(); diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index bf6591549..26b0d7f63 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -178,7 +178,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::getInstance()->applicationCloseLock()->tryLockForWrite(CLOSE_LOCK_TIMEOUT)) { + if (SystemFactory::instance()->applicationCloseLock()->tryLockForWrite(CLOSE_LOCK_TIMEOUT)) { // Application obtained permission to close // in a safety way. qDebug("Close lock obtained safely."); diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 31bccd89a..ebe275f17 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -415,7 +415,7 @@ void FormSettings::saveShortcuts() { void FormSettings::loadGeneral() { // Load auto-start status. - SystemFactory::AutoStartStatus autostart_status = SystemFactory::getInstance()->getAutoStartStatus(); + SystemFactory::AutoStartStatus autostart_status = SystemFactory::instance()->getAutoStartStatus(); switch (autostart_status) { case SystemFactory::Enabled: m_ui->m_checkAutostart->setChecked(true); @@ -438,10 +438,10 @@ void FormSettings::saveGeneral() { // If auto-start feature is available and user wants // to turn it on, then turn it on. if (m_ui->m_checkAutostart->isChecked()) { - SystemFactory::getInstance()->setAutoStartStatus(SystemFactory::Enabled); + SystemFactory::instance()->setAutoStartStatus(SystemFactory::Enabled); } else { - SystemFactory::getInstance()->setAutoStartStatus(SystemFactory::Disabled); + SystemFactory::instance()->setAutoStartStatus(SystemFactory::Disabled); } // Setup in-memory database status.