X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ff243261742ecd70fb9e417614e757b5956c04aa..7fe1278b1e2aaec2408bf053092f8f11ef4cbfdb:/src/views/versioncontrol/versioncontrolobserver.cpp diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index 20b059035..f4dd877d3 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -21,7 +21,6 @@ #include "dolphin_versioncontrolsettings.h" -#include #include #include #include @@ -30,6 +29,7 @@ #include "updateitemstatesthread.h" +#include #include #include @@ -90,7 +90,17 @@ KFileItemModel* VersionControlObserver::model() const QList VersionControlObserver::actions(const KFileItemList& items) const { QList actions; - if (!m_model) { + + bool hasNullItems = false; + foreach (const KFileItem& item, items) { + if (item.isNull()) { + kWarning() << "Requesting version-control-actions for empty items"; + hasNullItems = true; + break; + } + } + + if (!m_model || hasNullItems) { return actions; } @@ -146,8 +156,8 @@ void VersionControlObserver::verifyDirectory() return; } - const KUrl versionControlUrl = m_model->rootItem().url(); - if (!versionControlUrl.isLocalFile()) { + const KFileItem rootItem = m_model->rootItem(); + if (rootItem.isNull() || !rootItem.url().isLocalFile()) { return; } @@ -155,7 +165,7 @@ void VersionControlObserver::verifyDirectory() m_plugin->disconnect(this); } - m_plugin = searchPlugin(versionControlUrl); + m_plugin = searchPlugin(rootItem.url()); if (m_plugin) { KVersionControlPlugin2* pluginV2 = qobject_cast(m_plugin); if (pluginV2) { @@ -195,7 +205,7 @@ void VersionControlObserver::slotThreadFinished() UpdateItemStatesThread* thread = m_updateItemStatesThread; m_updateItemStatesThread = 0; // The thread deletes itself automatically (see updateItemStates()) - if (!m_plugin) { + if (!m_plugin || !thread) { return; } @@ -228,20 +238,12 @@ void VersionControlObserver::slotThreadFinished() void VersionControlObserver::updateItemStates() { Q_ASSERT(m_plugin); - if (!m_updateItemStatesThread) { - m_updateItemStatesThread = new UpdateItemStatesThread(); - connect(m_updateItemStatesThread, SIGNAL(finished()), - this, SLOT(slotThreadFinished())); - connect(m_updateItemStatesThread, SIGNAL(finished()), - m_updateItemStatesThread, SLOT(deleteLater())); - } - if (m_updateItemStatesThread->isRunning()) { + if (m_updateItemStatesThread) { // An update is currently ongoing. Wait until the thread has finished // the update (see slotThreadFinished()). m_pendingItemStatesUpdate = true; return; } - QList itemStates; const int itemCount = m_model->count(); itemStates.reserve(itemCount); @@ -259,7 +261,12 @@ void VersionControlObserver::updateItemStates() if (!m_silentUpdate) { emit infoMessage(i18nc("@info:status", "Updating version information...")); } - m_updateItemStatesThread->setData(m_plugin, itemStates); + m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates); + connect(m_updateItemStatesThread, SIGNAL(finished()), + this, SLOT(slotThreadFinished())); + connect(m_updateItemStatesThread, SIGNAL(finished()), + m_updateItemStatesThread, SLOT(deleteLater())); + m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished } } @@ -298,7 +305,6 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director // Verify whether the current directory contains revision information // like .svn, .git, ... foreach (KVersionControlPlugin* plugin, plugins) { - // Use the KDirLister cache to check for .svn, .git, ... files const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName(); if (QFile::exists(fileName)) { return plugin;