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

List:       kde-commits
Subject:    branches/KDE/4.3/kdebase/runtime/nepomuk/strigibackend
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-01-18 11:31:56
Message-ID: 1263814316.090946.29219.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1076569 by trueg:

Backport: fix crash for nested analysis results in addTriplet.

BUG: 220791


 M  +13 -9     sopranoindexwriter.cpp  


--- branches/KDE/4.3/kdebase/runtime/nepomuk/strigibackend/sopranoindexwriter.cpp #1076568:1076569
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
+   Copyright (C) 2007-2010 Sebastian Trueg <trueg@kde.org>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -40,6 +40,7 @@
 #include <QtCore/QDateTime>
 #include <QtCore/QByteArray>
 #include <QtCore/QUuid>
+#include <QtCore/QStack>
 
 #include <KUrl>
 
@@ -149,8 +150,7 @@
 {
 public:
     Private()
-        : indexTransactionID( 0 ),
-          currentResult( 0 ) {
+        : indexTransactionID( 0 ) {
         literalTypes[FieldRegister::stringType] = QVariant::String;
         literalTypes[FieldRegister::floatType] = QVariant::Double;
         literalTypes[FieldRegister::integerType] = QVariant::Int;
@@ -225,7 +225,7 @@
     // However, we only use one thread, only one AnalysisResult at the time.
     // Thus, we can just remember that and use it in addTriplet.
     //
-    const Strigi::AnalysisResult* currentResult;
+    QStack<const Strigi::AnalysisResult*> currentResultStack;
 
 private:
     QHash<std::string, QVariant::Type> literalTypes;
@@ -324,6 +324,9 @@
 // called for each indexed file
 void Strigi::Soprano::IndexWriter::startAnalysis( const AnalysisResult* idx )
 {
+    // we need to remember the AnalysisResult since addTriplet does not provide it
+    d->currentResultStack.push(idx);
+
     if ( idx->depth() > 0 ) {
         return;
     }
@@ -343,8 +346,6 @@
     }
 
     idx->setWriterData( data );
-
-    d->currentResult = idx;
 }
 
 
@@ -496,14 +497,17 @@
                                                const std::string& p,
                                                const std::string& o )
 {
+    if ( d->currentResultStack.top()->depth() > 0 ) {
+        return;
+    }
+
     //
     // The Strigi API does not provide context information here, i.e. the AnalysisResult this triple
     // belongs to. However, we only use one thread, only one AnalysisResult at the time.
     // Thus, we can just remember that and use it here.
     //
+    FileMetaData* md = static_cast<FileMetaData*>( d->currentResultStack.top()->writerData() );
 
-    FileMetaData* md = static_cast<FileMetaData*>( d->currentResult->writerData() );
-
     QUrl subject = d->mapNode( md, s );
     Nepomuk::Types::Property property( d->mapNode( md, p ) );
     ::Soprano::Node object;
@@ -519,7 +523,7 @@
 // called after each indexed file
 void Strigi::Soprano::IndexWriter::finishAnalysis( const AnalysisResult* idx )
 {
-    d->currentResult = 0;
+    d->currentResultStack.pop();
 
     if ( idx->depth() > 0 ) {
         return;
[prev in list] [next in list] [prev in thread] [next in thread] 

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