changeset 476:acddcc3cca36

* Avoid deadlock in indexer
author Chris Cannam
date Fri, 07 Nov 2008 20:25:57 +0000
parents a70dcfed59c1
children e0784311a103
files rdf/PluginRDFIndexer.cpp
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rdf/PluginRDFIndexer.cpp	Fri Nov 07 17:31:06 2008 +0000
+++ b/rdf/PluginRDFIndexer.cpp	Fri Nov 07 20:25:57 2008 +0000
@@ -161,10 +161,12 @@
 QString
 PluginRDFIndexer::getIdForPluginURI(QString uri)
 {
-    QMutexLocker locker(&m_mutex);
+    m_mutex.lock();
 
     if (m_uriToIdMap.find(uri) == m_uriToIdMap.end()) {
 
+        m_mutex.unlock();
+
         // Haven't found this uri referenced in any document on the
         // local filesystem; try resolving the pre-fragment part of
         // the uri as a document URL and reading that if possible.
@@ -178,12 +180,16 @@
 
         indexURL(baseUrl);
 
+        m_mutex.lock();
+
         if (m_uriToIdMap.find(uri) == m_uriToIdMap.end()) {
             m_uriToIdMap[uri] = "";
         }
     }
 
-    return m_uriToIdMap[uri];
+    QString id = m_uriToIdMap[uri];
+    m_mutex.unlock();
+    return id;
 }
 
 QString