274cf74a5c93 — Chris Cannam 7 years ago
Update to C++11, and make a fix to throw-from-dtor logic (i.e. don't do it) along with a few other compile and warning fixes.
M CHANGELOG +8 -0
@@ 1,3 1,11 @@ 
+
+Changes in Dataquay 0.9.1 since the previous version 0.9:
+
+ * Update to support Qt5 and newer C++ compilers. Now requires C++11
+   (though the library only makes minimal use of the standard).
+
+ * Incorporate a number of build fixes
+
 
 Changes in Dataquay 0.9 since the previous version 0.8:
 

          
M README.txt +3 -3
@@ 3,12 3,12 @@ Dataquay
 ========
 
 Dataquay is a free open source library that provides a friendly C++
-API for an RDF data store using Qt 4+ classes and containers.
+API for an RDF data store using Qt classes and containers.
 
   http://breakfastquay.com/dataquay/
 
-This is version 0.9 of Dataquay.  Note that this is a pre-1.0 release
-and the API is still subject to change.
+This is version 0.9.1 of Dataquay.  Note that this is a pre-1.0
+release and the API is still subject to change.
 
 Dataquay is simple to use and easy to integrate. It is principally
 intended for use in Qt-based applications that would like to use an

          
M config.pri +6 -6
@@ 2,12 2,12 @@ CONFIG -= debug
 CONFIG += release
 
 # Define these to use the Redland datastore (http://librdf.org/)
-#DEFINES += USE_REDLAND
-#QMAKE_CXXFLAGS += -I/usr/include/rasqal -I/usr/include/raptor2
-#EXTRALIBS += -lrdf
+DEFINES += USE_REDLAND
+QMAKE_CXXFLAGS += -I/usr/include/rasqal -I/usr/include/raptor2
+EXTRALIBS += -lrdf
 
 # Define this to use the Sord datastore (http://drobilla.net/software/sord/)
-DEFINES += USE_SORD
-QMAKE_CXXFLAGS += -I/usr/include/sord-0 -I/usr/include/serd-0
-EXTRALIBS += -lsord-0 -lserd-0
+#DEFINES += USE_SORD
+#QMAKE_CXXFLAGS += -I/usr/include/sord-0 -I/usr/include/serd-0 -Werror
+#EXTRALIBS += -lsord-0 -lserd-0
 

          
M examples/TransactionalCommand.cpp +2 -2
@@ 36,7 36,7 @@ 
 
 #include <memory>
 
-using std::auto_ptr;
+using std::unique_ptr;
 
 namespace Dataquay
 {

          
@@ 54,7 54,7 @@ TransactionalCommand::execute()
         m_store->change(m_cs);
         return;
     }
-    auto_ptr<Transaction> tx(m_store->startTransaction());
+    unique_ptr<Transaction> tx(m_store->startTransaction());
     performCommand(tx.get());
     m_cs = tx->getChanges();
     m_haveCs = true;

          
M lib.pro +1 -1
@@ 4,7 4,7 @@ exists(debug.pri) {
 }
 
 TEMPLATE = lib
-CONFIG += warn_on staticlib
+CONFIG += warn_on staticlib c++11
 QT -= gui
 
 TARGET = dataquay

          
M src/TransactionalStore.cpp +11 -13
@@ 40,9 40,9 @@ 
 #include <QMutexLocker>
 
 #include <iostream>
-#include <memory> // auto_ptr
+#include <memory> // unique_ptr
 
-using std::auto_ptr;
+using std::unique_ptr;
 
 namespace Dataquay
 {

          
@@ 337,13 337,11 @@ public:
     }
     ~D() {
         if (!m_committed && !m_abandoned && !m_tx->getChanges().empty()) {
-            // Although it's not a good idea for any code to try to
-            // catch this exception and continue (better just to fix
-            // the code!), we should at least make it possible -- so
             // we need to either commit or rollback, or else the next
             // transaction will stall
             m_td->rollbackTransaction(m_tx);
-            throw RDFTransactionError(QString("Transaction deleted without having been committed or rolled back"));
+            // Not good form to throw an exception from the dtor
+            std::cerr << "WARNING: Transaction deleted without having been committed or rolled back" << std::endl;
         }
     }
 

          
@@ 635,7 633,7 @@ TransactionalStore::import(QUrl url, Imp
     if (!m_d->hasWrap()) {
         throw RDFException("TransactionalStore::import() called without Transaction");
     }
-    auto_ptr<Transaction> tx(startTransaction());
+    unique_ptr<Transaction> tx(startTransaction());
     return tx->import(url, idm, format);
 }
 

          
@@ 651,8 649,8 @@ TransactionalStore::add(Triple t)
     if (!m_d->hasWrap()) {
         throw RDFException("TransactionalStore::add() called without Transaction");
     }
-    // auto_ptr here is very useful to ensure destruction on exceptions
-    auto_ptr<Transaction> tx(startTransaction());
+    // unique_ptr here is very useful to ensure destruction on exceptions
+    unique_ptr<Transaction> tx(startTransaction());
     return tx->add(t);
 }
 

          
@@ 662,7 660,7 @@ TransactionalStore::remove(Triple t)
     if (!m_d->hasWrap()) {
         throw RDFException("TransactionalStore::remove() called without Transaction");
     }
-    auto_ptr<Transaction> tx(startTransaction());
+    unique_ptr<Transaction> tx(startTransaction());
     return tx->remove(t);
 }
 

          
@@ 672,7 670,7 @@ TransactionalStore::change(ChangeSet cs)
     if (!m_d->hasWrap()) {
         throw RDFException("TransactionalStore::change() called without Transaction");
     }
-    auto_ptr<Transaction> tx(startTransaction());
+    unique_ptr<Transaction> tx(startTransaction());
     tx->change(cs);
 }
 

          
@@ 682,7 680,7 @@ TransactionalStore::revert(ChangeSet cs)
     if (!m_d->hasWrap()) {
         throw RDFException("TransactionalStore::revert() called without Transaction");
     }
-    auto_ptr<Transaction> tx(startTransaction());
+    unique_ptr<Transaction> tx(startTransaction());
     tx->revert(cs);
 }
 

          
@@ 741,7 739,7 @@ TransactionalStore::addBlankNode()
     if (!m_d->hasWrap()) {
         throw RDFException("TransactionalStore::addBlankNode() called without Transaction");
     }
-    auto_ptr<Transaction> tx(startTransaction());
+    unique_ptr<Transaction> tx(startTransaction());
     return tx->addBlankNode();
 }
 

          
M src/backend/BasicStoreRedland.cpp +0 -1
@@ 288,7 288,6 @@ public:
     Uri getUniqueUri(QString prefix) const {
         QMutexLocker locker(&m_librdfLock);
         DQ_DEBUG << "BasicStore::getUniqueUri: prefix " << prefix << endl;
-        int base = (int)(long)this; // we don't care at all about overflow
         bool good = false;
         Uri uri;
         while (!good) {

          
M src/objectmapper/ObjectStorer.cpp +1 -1
@@ 490,7 490,7 @@ ObjectStorer::D::storeProperties(StoreSt
 
         if (m_psp == StoreIfChanged) {
             if (m_ob->knows(cname)) {
-                std::auto_ptr<QObject> c(m_ob->build(cname, 0));
+                std::unique_ptr<QObject> c(m_ob->build(cname, 0));
                 QVariant deftValue = c->property(pnba.data());
                 if (variantsEqual(value, deftValue)) {
                     store = false;

          
M tests/TestBasicStore.h +1 -1
@@ 558,7 558,7 @@ private slots:
         // And loading it should result in URLs relative to the file
         // URL
 
-        BasicStore *s2 = BasicStore::load(QUrl("file://test3.ttl"));
+        BasicStore *s2 = BasicStore::load(QUrl("file:test3.ttl"));
         t = s2->matchOnce(Triple(Node(), Uri("a"), Node()));
         QCOMPARE(t.a, Node(Uri("file://test3.ttl#thing")));
         QCOMPARE(t.c, Node(Uri("file://test3.ttl#wotsit")));

          
M tests/TestTransactionalStore.h +6 -7
@@ 174,14 174,12 @@ private slots:
 	int added = 0;
 	QVERIFY(addThings(t, added));
 
-	try {
-	    delete t;
-	    QVERIFY(0);
-	} catch (RDFException) {
-	    QVERIFY(1);
-	}
+        // Logic has changed here -- we no longer throw from the
+        // dtor. Instead it just recovers, but a warning message is
+        // printed.
+        delete t;
 
-	// but check that this doesn't prevent any further
+	// and check that this doesn't prevent any further
 	// transactions from happening
 	t = ts->startTransaction();
 	t->rollback();

          
@@ 193,6 191,7 @@ private slots:
 	try {
 	    Transaction *tt = ts->startTransaction();
 	    QVERIFY(0);
+            tt->rollback();
 	} catch (RDFException) {
 	    QVERIFY(1);
 	}

          
M tests/tests.pro +4 -0
@@ 10,6 10,10 @@ exists(../config.pri) {
 	include(../config.pri)
 }
 
+!defined(DESTDIR) {
+    DESTDIR = ./
+}
+
 INCLUDEPATH += . ..
 DEPENDPATH += . ..
 QMAKE_LIBDIR += ..