diff rdf/SimpleSPARQLQuery.cpp @ 526:8878efd21dbc

* The main fix here is to the arguments of SVApplication -- the first one should be int& rather than int (was causing a crash! gah!) Various other tiny fixes
author Chris Cannam
date Fri, 09 Jan 2009 14:55:12 +0000
parents 7207e3eba44f
children 3c5570e3d9c5
line wrap: on
line diff
--- a/rdf/SimpleSPARQLQuery.cpp	Mon Jan 05 21:51:27 2009 +0000
+++ b/rdf/SimpleSPARQLQuery.cpp	Fri Jan 09 14:55:12 2009 +0000
@@ -255,7 +255,7 @@
 protected:
     static QMutex m_mutex;
 
-    static WredlandWorldWrapper m_redland;
+    static WredlandWorldWrapper *m_redland;
 
     ResultList executeDirectParser();
     ResultList executeDatastore();
@@ -268,7 +268,7 @@
     bool m_cancelled;
 };
 
-WredlandWorldWrapper SimpleSPARQLQuery::Impl::m_redland;
+WredlandWorldWrapper *SimpleSPARQLQuery::Impl::m_redland = 0;
 
 QMutex SimpleSPARQLQuery::Impl::m_mutex;
 
@@ -355,7 +355,11 @@
 
     QMutexLocker locker(&m_mutex);
 
-    if (!m_redland.isOK()) {
+    if (!m_redland) {
+        m_redland = new WredlandWorldWrapper();
+    }
+
+    if (!m_redland->isOK()) {
         cerr << "ERROR: SimpleSPARQLQuery::execute: Failed to initialise Redland datastore" << endl;
         return list;
     }
@@ -433,7 +437,7 @@
     {
         Profiler p("SimpleSPARQLQuery: Prepare LIBRDF query");
         query = librdf_new_query
-            (m_redland.getWorld(), "sparql", NULL,
+            (m_redland->getWorld(), "sparql", NULL,
              (const unsigned char *)m_query.toUtf8().data(), NULL);
     }
     
@@ -445,7 +449,7 @@
     librdf_query_results *results;
     {
         Profiler p("SimpleSPARQLQuery: Execute LIBRDF query");
-        results = librdf_query_execute(query, m_redland.getModel(modelUri));
+        results = librdf_query_execute(query, m_redland->getModel(modelUri));
     }
 
     if (!results) {
@@ -579,12 +583,12 @@
 
     QMutexLocker locker(&m_mutex);
 
-    if (!m_redland.isOK()) {
+    if (!m_redland->isOK()) {
         std::cerr << "SimpleSPARQLQuery::addSourceToModel: Failed to initialise Redland datastore" << std::endl;
         return false;
     }
 
-    if (!m_redland.loadUriIntoDefaultModel(sourceUri, err)) {
+    if (!m_redland->loadUriIntoDefaultModel(sourceUri, err)) {
         std::cerr << "SimpleSPARQLQuery::addSourceToModel: Failed to add source URI \"" << sourceUri.toStdString() << ": " << err.toStdString() << std::endl;
         return false;
     }
@@ -596,7 +600,7 @@
 {
     QMutexLocker locker(&m_mutex);
 
-    m_redland.freeModel(sourceUri);
+    m_redland->freeModel(sourceUri);
 }
 
 SimpleSPARQLQuery::Value