[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/nepomuk/core
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-11-19 14:52:34
Message-ID: 20101119145234.4E756AC8A0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1198743 by trueg:

Properly lock the ResourceData before [de]ref'ing it. We need to do this since other \
than QSharedData ResourceData instances are also referenced in ResourceManager.
This fixes a crash in the query service.

 M  +9 -0      resource.cpp  
 M  +10 -10    resourcedata.cpp  
 M  +0 -2      resourcemanager.cpp  


--- trunk/KDE/kdelibs/nepomuk/core/resource.cpp #1198742:1198743
@@ -47,6 +47,7 @@
 
 Nepomuk::Resource::Resource()
 {
+    QMutexLocker lock( &ResourceManager::instance()->d->mutex );
     m_data = ResourceManager::instance()->d->data( QUrl(), QUrl() );
     if ( m_data )
         m_data->ref( this );
@@ -55,6 +56,7 @@
 
 Nepomuk::Resource::Resource( ResourceManager* manager )
 {
+    QMutexLocker lock( &manager->d->mutex );
     m_data = manager->d->data( QUrl(), QUrl() );
     if ( m_data )
         m_data->ref( this );
@@ -71,6 +73,7 @@
 
 Nepomuk::Resource::Resource( const QString& uri, const QUrl& type )
 {
+    QMutexLocker lock( &ResourceManager::instance()->d->mutex );
     m_data = ResourceManager::instance()->d->data( uri, type );
     if ( m_data )
         m_data->ref( this );
@@ -79,6 +82,7 @@
 
 Nepomuk::Resource::Resource( const QString& uri, const QUrl& type, ResourceManager* \
manager )  {
+    QMutexLocker lock( &manager->d->mutex );
     m_data = manager->d->data( uri, type );
     if ( m_data )
         m_data->ref( this );
@@ -88,6 +92,7 @@
 #ifndef KDE_NO_DEPRECATED
 Nepomuk::Resource::Resource( const QString& uri, const QString& type )
 {
+    QMutexLocker lock( &ResourceManager::instance()->d->mutex );
     m_data = ResourceManager::instance()->d->data( uri, type );
     if ( m_data )
         m_data->ref( this );
@@ -97,6 +102,7 @@
 
 Nepomuk::Resource::Resource( const QUrl& uri, const QUrl& type )
 {
+    QMutexLocker lock( &ResourceManager::instance()->d->mutex );
     m_data = ResourceManager::instance()->d->data( uri, type );
     if ( m_data )
         m_data->ref( this );
@@ -105,6 +111,7 @@
 
 Nepomuk::Resource::Resource( const QUrl& uri, const QUrl& type, ResourceManager* \
manager )  {
+    QMutexLocker lock( &manager->d->mutex );
     m_data = manager->d->data( uri, type );
     if ( m_data )
         m_data->ref( this );
@@ -122,6 +129,7 @@
 Nepomuk::Resource::~Resource()
 {
     if ( m_data ) {
+        QMutexLocker lock(&m_data->rm()->mutex);
         m_data->deref( this );
         if ( m_data->rm()->shouldBeDeleted( m_data ) )
             delete m_data;
@@ -132,6 +140,7 @@
 Nepomuk::Resource& Nepomuk::Resource::operator=( const Resource& res )
 {
     if( m_data != res.m_data ) {
+        QMutexLocker lock(&m_data->rm()->mutex);
         if ( m_data && !m_data->deref( this ) && m_data->rm()->shouldBeDeleted( \
m_data ) ) {  delete m_data;
         }
--- trunk/KDE/kdelibs/nepomuk/core/resourcedata.cpp #1198742:1198743
@@ -629,23 +629,23 @@
 {
     load();
     if( !m_pimoThing ) {
-        if( hasType( Vocabulary::PIMO::Thing() ) ) {
-//            kDebug() << "we are already a thing. Creating link to ourself" << \
                m_uri << this;
-            // we are out own thing
-            m_pimoThing = new Thing(this);
-        }
-        else if( isFile() ) {
-            // files are a special case in every aspect. this includes pimo things.
-            // files are their own grounding occurrence. This makes a lot of things
+        //
+        // We only create a new thing if we are a nie:InformationElement.
+        // All other resources will simply be converted into a pimo:Thing
+        //
+        // Files, however, are a special case in every aspect. this includes pimo \
things. +        // Files are their own grounding occurrence. This makes a lot of \
things  // much simpler.
+        //
+        if( hasType( Vocabulary::PIMO::Thing() ) ||
+                isFile() ||
+                !hasType( Vocabulary::NIE::InformationElement() ) ) {
             m_pimoThing = new Thing(this);
         }
         else {
-//            kDebug() << "creating new thing for" << m_uri << m_types << this;
             m_pimoThing = new Thing();
         }
         m_pimoThing->m_data->m_groundingOccurence = this;
-//        kDebug() << "created thing" << m_pimoThing->m_data << "with grounding \
occurence" << m_pimoThing->m_data->m_groundingOccurence;  }
     return *m_pimoThing;
 }
--- trunk/KDE/kdelibs/nepomuk/core/resourcemanager.cpp #1198742:1198743
@@ -71,7 +71,6 @@
         return data;
     }
     else {
-        QMutexLocker lock( &mutex );
         return new ResourceData( QUrl(), uri, type, this );
     }
 }
@@ -99,7 +98,6 @@
         return data;
     }
     else {
-        QMutexLocker lock( &mutex );
         return new ResourceData( uri, QUrl(), type, this );
     }
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic