#include "updateitemstatesthread.h"
-UpdateItemStatesThread::UpdateItemStatesThread(QObject* parent) :
- QThread(parent),
+UpdateItemStatesThread::UpdateItemStatesThread() :
+ QThread(),
m_retrievedItems(false),
- m_mutex(QMutex::Recursive),
+ m_mutex(0),
m_itemStates()
{
+ // Several threads may share one instance of a plugin. A global
+ // mutex is required to serialize the retrieval of version control
+ // states inside run().
+ static QMutex globalMutex;
+ m_mutex = &globalMutex;
}
UpdateItemStatesThread::~UpdateItemStatesThread()
// VersionControlObserver::addDirectory() to be sure that the last item contains the root.
const QString directory = m_itemStates.last().item.url().directory(KUrl::AppendTrailingSlash);
- QMutexLocker locker(&m_mutex);
+ QMutexLocker locker(m_mutex);
m_retrievedItems = false;
if (m_plugin->beginRetrieval(directory)) {
const int count = m_itemStates.count();
bool UpdateItemStatesThread::beginReadItemStates()
{
- return m_mutex.tryLock(300);
+ return m_mutex->tryLock(300);
}
void UpdateItemStatesThread::endReadItemStates()
{
- m_mutex.unlock();
+ m_mutex->unlock();
}
QList<VersionControlObserver::ItemState> UpdateItemStatesThread::itemStates() const
return m_retrievedItems;
}
-void UpdateItemStatesThread::deleteWhenFinished()
-{
- connect(this, SIGNAL(finished()), this, SLOT(slotFinished()));
-}
-
-void UpdateItemStatesThread::slotFinished()
-{
- deleteLater();
-}
-
#include "updateitemstatesthread.moc"