[qet] [1365] Lock-related improvement in ElementsCollectionCache.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 1365
Author:   xavier
Date:     2011-10-08 23:51:38 +0200 (Sat, 08 Oct 2011)
Log Message:
-----------
Lock-related improvement in ElementsCollectionCache.

Modified Paths:
--------------
    branches/0.3/sources/elementscollectioncache.cpp

Modified: branches/0.3/sources/elementscollectioncache.cpp
===================================================================
--- branches/0.3/sources/elementscollectioncache.cpp	2011-10-08 06:06:22 UTC (rev 1364)
+++ branches/0.3/sources/elementscollectioncache.cpp	2011-10-08 21:51:38 UTC (rev 1365)
@@ -17,7 +17,7 @@
 	// initialize the cache SQLite database
 	static int cache_instances = 0;
 	QString connection_name = QString("ElementsCollectionCache-%1").arg(cache_instances++);
-	cache_db_ = QSqlDatabase::addDatabase("QSQLITE", connection_name );
+	cache_db_ = QSqlDatabase::addDatabase("QSQLITE", connection_name);
 	cache_db_.setDatabaseName(database_path);
 	if (!cache_db_.open()) {
 		qDebug() << "Unable to open the SQLite database " << database_path << " as " << connection_name << ": " << cache_db_.lastError();
@@ -108,7 +108,11 @@
 	bool use_cache = cache_db_.isOpen() && collection -> isCacheable();
 	if (use_cache) {
 		bool transaction_commited = cache_db_.commit();
-		qDebug() << (transaction_commited ? "transaction commited for " : "transaction not commited for") << collection -> protocol();
+		if (transaction_commited) {
+			qDebug() << "transaction commited for " << collection -> protocol();
+		} else {
+			qDebug() << "transaction not commited for " << collection -> protocol() << ":" << cache_db_.lastError();
+		}
 	}
 }
 
@@ -192,6 +196,7 @@
 	if (select_name_ -> exec()) {
 		if (select_name_ -> first()) {
 			current_name_ = select_name_ -> value(0).toString();
+			select_name_ -> finish();
 			return(true);
 		}
 	} else {
@@ -217,6 +222,7 @@
 			// avoid returning always the same pixmap (i.e. same cacheKey())
 			current_pixmap_.detach();
 			current_pixmap_.loadFromData(ba, qPrintable(pixmap_storage_format_));
+			select_pixmap_ -> finish();
 		}
 		return(true);
 	} else {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/