┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2010-03-24 22:41:06 +0000
committerPeter Penz <[email protected]>2010-03-24 22:41:06 +0000
commitd197a7e5319cb86ab3479c23828af226365d6049 (patch)
tree1943899cb51baa444d69cd6bcf5f62aea0f993ba
parent884e95cc985ccf3a7d9de9ebe0d9b1bbd2d9e706 (diff)
Renamed methods and improved documentation, as in the previous patch the wrong mutex has been used accidently because of the confusing naming of the methods.
svn path=/trunk/KDE/kdebase/apps/; revision=1107136
-rw-r--r--src/versioncontrol/updateitemstatesthread.cpp8
-rw-r--r--src/versioncontrol/updateitemstatesthread.h23
-rw-r--r--src/versioncontrol/versioncontrolobserver.cpp8
3 files changed, 29 insertions, 10 deletions
diff --git a/src/versioncontrol/updateitemstatesthread.cpp b/src/versioncontrol/updateitemstatesthread.cpp
index 020cdb0d0..57c4481c3 100644
--- a/src/versioncontrol/updateitemstatesthread.cpp
+++ b/src/versioncontrol/updateitemstatesthread.cpp
@@ -76,14 +76,14 @@ void UpdateItemStatesThread::run()
}
}
-bool UpdateItemStatesThread::beginReadItemStates()
+bool UpdateItemStatesThread::lockPlugin()
{
- return m_itemMutex.tryLock(300);
+ return m_globalPluginMutex->tryLock(300);
}
-void UpdateItemStatesThread::endReadItemStates()
+void UpdateItemStatesThread::unlockPlugin()
{
- m_itemMutex.unlock();
+ m_globalPluginMutex->unlock();
}
QList<VersionControlObserver::ItemState> UpdateItemStatesThread::itemStates() const
diff --git a/src/versioncontrol/updateitemstatesthread.h b/src/versioncontrol/updateitemstatesthread.h
index f99188014..8467c87d7 100644
--- a/src/versioncontrol/updateitemstatesthread.h
+++ b/src/versioncontrol/updateitemstatesthread.h
@@ -41,11 +41,30 @@ public:
UpdateItemStatesThread();
virtual ~UpdateItemStatesThread();
+ /**
+ * @param plugin Version control plugin that is used to update the
+ * state of the items. Whenever the plugin is accessed
+ * from the thread creator after starting the thread,
+ * UpdateItemStatesThread::lockPlugin() and
+ * UpdateItemStatesThread::unlockPlugin() must be used.
+ * @param itemStates List of items, where the states get updated.
+ */
void setData(KVersionControlPlugin* plugin,
const QList<VersionControlObserver::ItemState>& itemStates);
- bool beginReadItemStates();
- void endReadItemStates();
+ /**
+ * Whenever the plugin is accessed by the thread creator, lockPlugin() must
+ * be invoked. True is returned, if the plugin could be locked within 300
+ * milliseconds.
+ */
+ bool lockPlugin();
+
+ /**
+ * Must be invoked if lockPlugin() returned true and plugin has been accessed
+ * by the thread creator.
+ */
+ void unlockPlugin();
+
QList<VersionControlObserver::ItemState> itemStates() const;
bool retrievedItems() const;
diff --git a/src/versioncontrol/versioncontrolobserver.cpp b/src/versioncontrol/versioncontrolobserver.cpp
index cab62be39..c1ef4b54b 100644
--- a/src/versioncontrol/versioncontrolobserver.cpp
+++ b/src/versioncontrol/versioncontrolobserver.cpp
@@ -99,9 +99,9 @@ VersionControlObserver::~VersionControlObserver()
QList<QAction*> VersionControlObserver::contextMenuActions(const KFileItemList& items) const
{
QList<QAction*> actions;
- if (isVersioned() && m_updateItemStatesThread->beginReadItemStates()) {
+ if (isVersioned() && m_updateItemStatesThread->lockPlugin()) {
actions = m_plugin->contextMenuActions(items);
- m_updateItemStatesThread->endReadItemStates();
+ m_updateItemStatesThread->unlockPlugin();
}
return actions;
}
@@ -109,9 +109,9 @@ QList<QAction*> VersionControlObserver::contextMenuActions(const KFileItemList&
QList<QAction*> VersionControlObserver::contextMenuActions(const QString& directory) const
{
QList<QAction*> actions;
- if (isVersioned() && m_updateItemStatesThread->beginReadItemStates()) {
+ if (isVersioned() && m_updateItemStatesThread->lockPlugin()) {
actions = m_plugin->contextMenuActions(directory);
- m_updateItemStatesThread->endReadItemStates();
+ m_updateItemStatesThread->unlockPlugin();
}
return actions;