Debugging slowness in kmail showed me an issue there:

209│ bool Nepomuk2::Resource::hasProperty( const QUrl& uri ) const
210│ {
211├>    determineFinalResourceData();
212│     return m_data->hasProperty( uri );
213│ }

Even though we prepare the resource in a different thread (in 
asyncnepomukretriever) so all props are available, we're waiting on the 
ResourceManager mutex in that method, to read the properties.

Ah, but determineUri() does nothing if m_uri is set (not empty), anyway.
So how about the attached patch?

Note that I detected an error in the use of the "modification mutex" within 
Resource. I had used it only for "writes" to variables, but obviously the 
reads must be mutex-protected too. Now that I understand the C++11 memory 
model, it's a lot clearer :)
I'll rename the mutex then, it's not a "modification mutex", it's a mutex for 
the resource member variables.

Anyhow, please validate the URI thing -- am I right that it's empty initially,  
and then it's set (in determineUri()), and then never changed again?

-- 
David Faure, [email protected], http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5
diff --git a/libnepomukcore/resource/resource.cpp b/libnepomukcore/resource/resource.cpp
index df02be7..7158802 100644
--- a/libnepomukcore/resource/resource.cpp
+++ b/libnepomukcore/resource/resource.cpp
@@ -696,6 +696,10 @@ Nepomuk2::Resource Nepomuk2::Resource::fromResourceUri( const KUrl& uri, const N
 
 void Nepomuk2::Resource::determineFinalResourceData() const
 {
+    if (!m_data->uri().isEmpty()) {
+        return;
+    }
+
     QMutexLocker lock( &m_data->rm()->mutex );
 
     // Get an initialized ResourceData instance
diff --git a/libnepomukcore/resource/resourcedata.cpp b/libnepomukcore/resource/resourcedata.cpp
index b4c4bcc..84ab3df 100644
--- a/libnepomukcore/resource/resourcedata.cpp
+++ b/libnepomukcore/resource/resourcedata.cpp
@@ -106,6 +106,7 @@ Nepomuk2::ResourceData::~ResourceData()
 
 bool Nepomuk2::ResourceData::isFile()
 {
+    QMutexLocker lock(&m_modificationMutex);
     return( m_uri.scheme() == QLatin1String("file") ||
             m_nieUrl.scheme() == QLatin1String("file") ||
             hasProperty( RDF::type(), NFO::FileDataObject() ) );
@@ -115,6 +116,7 @@ bool Nepomuk2::ResourceData::isFile()
 
 QUrl Nepomuk2::ResourceData::uri() const
 {
+    QMutexLocker lock(&m_modificationMutex);
     return m_uri;
 }
 
@@ -156,6 +158,7 @@ QUrl Nepomuk2::ResourceData::type()
 
 void Nepomuk2::ResourceData::resetAll( bool isDelete )
 {
+    QMutexLocker locker(&m_modificationMutex);
     // remove us from all caches (store() will re-insert us later if necessary)
     m_rm->mutex.lock();
 
@@ -176,7 +179,6 @@ void Nepomuk2::ResourceData::resetAll( bool isDelete )
     m_rm->mutex.unlock();
 
     // reset all variables
-    QMutexLocker locker(&m_modificationMutex);
     m_uri.clear();
     m_nieUrl.clear();
     m_naoIdentifier.clear();
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk

Reply via email to