]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Renamed methods and improved documentation, as in the previous patch the wrong mutex...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 24 Mar 2010 22:41:06 +0000 (22:41 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 24 Mar 2010 22:41:06 +0000 (22:41 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1107136

src/versioncontrol/updateitemstatesthread.cpp
src/versioncontrol/updateitemstatesthread.h
src/versioncontrol/versioncontrolobserver.cpp

index 020cdb0d052b83c1545d3796918740888a5e3800..57c4481c3effddac224f466b5a2e69c3554ba668 100644 (file)
@@ -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
index f99188014d3db58324ccb7cf0a2937c9ce1e4382..8467c87d7e2313b625f8cbb015c13d96fc98ad1f 100644 (file)
@@ -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;
index cab62be39d6b7619a972b2c17a4d8bae339e0a55..c1ef4b54b77228dcb4df43e098032ba4ae2a9877 100644 (file)
@@ -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;