X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/896ee459af10c73d20d0ae093b4c02348ffedb18..4cd0b00f0d94dcfac43306235dc96df86dc0ad0a:/src/versioncontrol/versioncontrolobserver.cpp diff --git a/src/versioncontrol/versioncontrolobserver.cpp b/src/versioncontrol/versioncontrolobserver.cpp index aea60b28d..c1ef4b54b 100644 --- a/src/versioncontrol/versioncontrolobserver.cpp +++ b/src/versioncontrol/versioncontrolobserver.cpp @@ -20,6 +20,7 @@ #include "versioncontrolobserver.h" #include +#include "dolphin_versioncontrolsettings.h" #include #include @@ -27,6 +28,7 @@ #include #include +#include "pendingthreadsmaintainer.h" #include "updateitemstatesthread.h" #include @@ -73,19 +75,33 @@ VersionControlObserver::VersionControlObserver(QAbstractItemView* view) : VersionControlObserver::~VersionControlObserver() { if (m_updateItemStatesThread != 0) { - disconnect(m_updateItemStatesThread, SIGNAL(finished()), - this, SLOT(applyUpdatedItemStates())); - m_updateItemStatesThread->deleteWhenFinished(); - m_updateItemStatesThread = 0; + if (m_updateItemStatesThread->isFinished()) { + delete m_updateItemStatesThread; + m_updateItemStatesThread = 0; + } else { + // The version controller gets deleted, while a thread still + // is working to get the version information. To avoid a blocking + // user interface, the thread will be forwarded to the + // PendingThreadsMaintainer, which will delete the thread later. + disconnect(m_updateItemStatesThread, SIGNAL(finished()), + this, SLOT(slotThreadFinished())); + PendingThreadsMaintainer::instance().append(m_updateItemStatesThread); + m_updateItemStatesThread = 0; + } + } + + if (m_plugin != 0) { + m_plugin->disconnect(); + m_plugin = 0; } } QList VersionControlObserver::contextMenuActions(const KFileItemList& items) const { QList actions; - if (isVersioned() && m_updateItemStatesThread->beginReadItemStates()) { + if (isVersioned() && m_updateItemStatesThread->lockPlugin()) { actions = m_plugin->contextMenuActions(items); - m_updateItemStatesThread->endReadItemStates(); + m_updateItemStatesThread->unlockPlugin(); } return actions; } @@ -93,9 +109,9 @@ QList VersionControlObserver::contextMenuActions(const KFileItemList& QList VersionControlObserver::contextMenuActions(const QString& directory) const { QList actions; - if (isVersioned() && m_updateItemStatesThread->beginReadItemStates()) { + if (isVersioned() && m_updateItemStatesThread->lockPlugin()) { actions = m_plugin->contextMenuActions(directory); - m_updateItemStatesThread->endReadItemStates(); + m_updateItemStatesThread->unlockPlugin(); } return actions; @@ -169,8 +185,12 @@ void VersionControlObserver::verifyDirectory() } } -void VersionControlObserver::applyUpdatedItemStates() +void VersionControlObserver::slotThreadFinished() { + if (m_plugin == 0) { + return; + } + if (!m_updateItemStatesThread->retrievedItems()) { // ignore m_silentUpdate for an error message emit errorMessage(i18nc("@info:status", "Update of version information failed.")); @@ -200,7 +220,7 @@ void VersionControlObserver::applyUpdatedItemStates() // operation has been completed because of the icon emblems. emit operationCompletedMessage(QString()); } - + if (m_pendingItemStatesUpdate) { m_pendingItemStatesUpdate = false; updateItemStates(); @@ -211,13 +231,13 @@ void VersionControlObserver::updateItemStates() { Q_ASSERT(m_plugin != 0); if (m_updateItemStatesThread == 0) { - m_updateItemStatesThread = new UpdateItemStatesThread(this); + m_updateItemStatesThread = new UpdateItemStatesThread(); connect(m_updateItemStatesThread, SIGNAL(finished()), - this, SLOT(applyUpdatedItemStates())); + this, SLOT(slotThreadFinished())); } if (m_updateItemStatesThread->isRunning()) { // An update is currently ongoing. Wait until the thread has finished - // the update (see applyUpdatedItemStates()). + // the update (see slotThreadFinished()). m_pendingItemStatesUpdate = true; return; } @@ -229,7 +249,7 @@ void VersionControlObserver::updateItemStates() emit infoMessage(i18nc("@info:status", "Updating version information...")); } m_updateItemStatesThread->setData(m_plugin, itemStates); - m_updateItemStatesThread->start(); // applyUpdatedItemStates() is called when finished + m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished } } @@ -263,11 +283,16 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director if (plugins.isEmpty()) { // No searching for plugins has been done yet. Query the KServiceTypeTrader for // all fileview version control plugins and remember them in 'plugins'. + const QString disabledPlugins = VersionControlSettings::disabledPlugins(); + const QStringList disabledPluginsList = disabledPlugins.split(','); + const KService::List pluginServices = KServiceTypeTrader::self()->query("FileViewVersionControlPlugin"); for (KService::List::ConstIterator it = pluginServices.constBegin(); it != pluginServices.constEnd(); ++it) { - KVersionControlPlugin* plugin = (*it)->createInstance(); - Q_ASSERT(plugin != 0); - plugins.append(plugin); + if (!disabledPluginsList.contains((*it)->name())) { + KVersionControlPlugin* plugin = (*it)->createInstance(); + Q_ASSERT(plugin != 0); + plugins.append(plugin); + } } if (plugins.isEmpty()) { pluginsAvailable = false;