]>
cloud.milkyroute.net Git - dolphin.git/blob - src/views/versioncontrol/updateitemstatesthread.cpp
cf45bbff16325354045abd3702be0440ff741335
2 * SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #include "updateitemstatesthread.h"
10 UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin
* plugin
,
11 const QMap
<QString
, QVector
<VersionControlObserver::ItemState
> >& itemStates
) :
13 m_globalPluginMutex(nullptr),
15 m_itemStates(itemStates
)
17 // Several threads may share one instance of a plugin. A global
18 // mutex is required to serialize the retrieval of version control
19 // states inside run().
20 static QMutex globalMutex
;
21 m_globalPluginMutex
= &globalMutex
;
24 UpdateItemStatesThread::~UpdateItemStatesThread()
28 void UpdateItemStatesThread::run()
30 Q_ASSERT(!m_itemStates
.isEmpty());
33 QMutexLocker
pluginLocker(m_globalPluginMutex
);
34 QMap
<QString
, QVector
<VersionControlObserver::ItemState
> >::iterator it
= m_itemStates
.begin();
35 for (; it
!= m_itemStates
.end(); ++it
) {
36 if (m_plugin
->beginRetrieval(it
.key())) {
37 QVector
<VersionControlObserver::ItemState
>& items
= it
.value();
38 const int count
= items
.count();
39 for (int i
= 0; i
< count
; ++i
) {
40 const KFileItem
& item
= items
.at(i
).first
;
41 const KVersionControlPlugin::ItemVersion version
= m_plugin
->itemVersion(item
);
42 items
[i
].second
= version
;
46 m_plugin
->endRetrieval();
50 QMap
<QString
, QVector
<VersionControlObserver::ItemState
> > UpdateItemStatesThread::itemStates() const