#include "dolphin_versioncontrolsettings.h"
-#include <KDirLister>
#include <KLocale>
#include <KService>
#include <KServiceTypeTrader>
#include "updateitemstatesthread.h"
+#include <QFile>
#include <QMutexLocker>
#include <QTimer>
QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
{
QList<QAction*> 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;
}
if (pluginV2) {
// Use version 2 of the KVersionControlPlugin which allows providing actions
// also for non-versioned directories.
- if (m_updateItemStatesThread && m_updateItemStatesThread->lockPlugin()) {
- actions = pluginV2->actions(items);
- m_updateItemStatesThread->unlockPlugin();
- } else {
- actions = pluginV2->actions(items);
- }
+ actions = pluginV2->actions(items);
} else if (isVersioned()) {
// Support deprecated interfaces from KVersionControlPlugin version 1.
// Context menu actions where only available for versioned directories.
}
}
- if (m_updateItemStatesThread && m_updateItemStatesThread->lockPlugin()) {
- actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
- : m_plugin->contextMenuActions(directory);
- m_updateItemStatesThread->unlockPlugin();
- } else {
- actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
- : m_plugin->contextMenuActions(directory);
- }
+ actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
+ : m_plugin->contextMenuActions(directory);
}
return actions;
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<ItemState> itemStates;
const int itemCount = m_model->count();
itemStates.reserve(itemCount);
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
}
}
// 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;