mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Fix race condition and deadlock in the version plugin
when listing directories is slow. BUG: 302264 FIXED-IN: 4.9.3
This commit is contained in:
parent
9685cba808
commit
b4c01c00a9
1 changed files with 7 additions and 4 deletions
|
@ -45,10 +45,12 @@ UpdateItemStatesThread::~UpdateItemStatesThread()
|
|||
void UpdateItemStatesThread::setData(KVersionControlPlugin* plugin,
|
||||
const QList<VersionControlObserver::ItemState>& itemStates)
|
||||
{
|
||||
QMutexLocker itemLocker(&m_itemMutex);
|
||||
m_itemStates = itemStates;
|
||||
|
||||
// The locks are taken in the same order as in run()
|
||||
// to avoid potential deadlock.
|
||||
QMutexLocker pluginLocker(m_globalPluginMutex);
|
||||
QMutexLocker itemLocker(&m_itemMutex);
|
||||
|
||||
m_itemStates = itemStates;
|
||||
m_plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -58,11 +60,12 @@ void UpdateItemStatesThread::run()
|
|||
Q_ASSERT(m_plugin);
|
||||
|
||||
QMutexLocker itemLocker(&m_itemMutex);
|
||||
|
||||
const QString directory = m_itemStates.first().item.url().directory(KUrl::AppendTrailingSlash);
|
||||
m_retrievedItems = false;
|
||||
itemLocker.unlock();
|
||||
|
||||
QMutexLocker pluginLocker(m_globalPluginMutex);
|
||||
m_retrievedItems = false;
|
||||
if (m_plugin->beginRetrieval(directory)) {
|
||||
itemLocker.relock();
|
||||
const int count = m_itemStates.count();
|
||||
|
|
Loading…
Reference in a new issue