]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/versioncontrol/versioncontrolobserver.cpp
Get back names, and use "using" keyword to keep GCC silent on "method foo on base...
[dolphin.git] / src / versioncontrol / versioncontrolobserver.cpp
index aea60b28d86a3021233af190ff31160fc4652a98..ebe59e049af49847e4f3c1351e2445046df9cf8e 100644 (file)
@@ -20,6 +20,7 @@
 #include "versioncontrolobserver.h"
 
 #include <dolphinmodel.h>
+#include "dolphin_versioncontrolsettings.h"
 
 #include <kdirlister.h>
 #include <klocale.h>
@@ -75,9 +76,16 @@ VersionControlObserver::~VersionControlObserver()
     if (m_updateItemStatesThread != 0) {
         disconnect(m_updateItemStatesThread, SIGNAL(finished()),
                    this, SLOT(applyUpdatedItemStates()));
-        m_updateItemStatesThread->deleteWhenFinished();
+        if (m_updateItemStatesThread->isFinished()) {
+            delete m_updateItemStatesThread;
+        } else {
+            m_updateItemStatesThread->deleteWhenFinished();
+        }
         m_updateItemStatesThread = 0;
     }
+
+    m_plugin->disconnect();
+    m_plugin = 0;
 }
 
 QList<QAction*> VersionControlObserver::contextMenuActions(const KFileItemList& items) const
@@ -171,6 +179,12 @@ void VersionControlObserver::verifyDirectory()
 
 void VersionControlObserver::applyUpdatedItemStates()
 {
+    if (m_plugin == 0) {
+        // The signal finished() has been emitted, but the thread has been marked
+        // as invalid in the meantime. Just ignore the signal in this case.
+        return;
+    }
+
     if (!m_updateItemStatesThread->retrievedItems()) {
         // ignore m_silentUpdate for an error message
         emit errorMessage(i18nc("@info:status", "Update of version information failed."));
@@ -211,7 +225,7 @@ 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()));
     }
@@ -263,11 +277,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<KVersionControlPlugin>();
-            Q_ASSERT(plugin != 0);
-            plugins.append(plugin);
+            if (!disabledPluginsList.contains((*it)->name())) {
+                KVersionControlPlugin* plugin = (*it)->createInstance<KVersionControlPlugin>();
+                Q_ASSERT(plugin != 0);
+                plugins.append(plugin);
+            }
         }
         if (plugins.isEmpty()) {
             pluginsAvailable = false;