]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/versioncontrol/updateitemstatesthread.cpp
Use KFileMetaDataWidget from kdelibs. Still open: Provide dialog which wraps KFileMet...
[dolphin.git] / src / versioncontrol / updateitemstatesthread.cpp
index 7483e056e9b5db52f90dd3fc2a4550ef331f4001..0cd5b93e15ad129d5f4e73a8477d6380bf1234ac 100644 (file)
 
 #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()
@@ -49,7 +54,7 @@ void UpdateItemStatesThread::run()
     // 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();
@@ -63,12 +68,12 @@ void UpdateItemStatesThread::run()
 
 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
@@ -81,14 +86,4 @@ bool UpdateItemStatesThread::retrievedItems() const
     return m_retrievedItems;
 }
 
-void UpdateItemStatesThread::deleteWhenFinished()
-{
-    connect(this, SIGNAL(finished()), this, SLOT(slotFinished()));
-}
-
-void UpdateItemStatesThread::slotFinished()
-{
-    deleteLater();
-}
-
 #include "updateitemstatesthread.moc"