From 7c9ae062101b5dc8f963c70fb753f8346a9b5c48 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 12 Aug 2015 01:03:21 +0200 Subject: Use nested transactions in the messagequeue --- common/messagequeue.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'common/messagequeue.cpp') diff --git a/common/messagequeue.cpp b/common/messagequeue.cpp index d2e285a..84385ca 100644 --- a/common/messagequeue.cpp +++ b/common/messagequeue.cpp @@ -29,18 +29,14 @@ void MessageQueue::dequeue(const std::function &errorHandler) { bool readValue = false; - auto readTransaction = std::move(mStorage.createTransaction(Akonadi2::Storage::ReadOnly)); - readTransaction.scan("", [this, resultHandler, errorHandler, &readValue, &readTransaction](const QByteArray &key, const QByteArray &value) -> bool { + mStorage.createTransaction(Akonadi2::Storage::ReadOnly).scan("", [this, resultHandler, errorHandler, &readValue](const QByteArray &key, const QByteArray &value) -> bool { if (Akonadi2::Storage::isInternalKey(key)) { return true; } readValue = true; //We need a copy of the key here, otherwise we can't store it in the lambda (the pointers will become invalid) const auto keyCopy = QByteArray(key.constData(), key.size()); - //TODO The value copy and the early transaction abort is necessary because we don't support parallel read-transactions yet (in case of a synchronous callback) - const auto valueCopy = QByteArray(value.constData(), value.size()); - readTransaction.abort(); - resultHandler(const_cast(static_cast(valueCopy.data())), valueCopy.size(), [this, keyCopy, errorHandler](bool success) { + resultHandler(const_cast(static_cast(value.data())), value.size(), [this, keyCopy, errorHandler](bool success) { if (success) { mStorage.createTransaction(Akonadi2::Storage::ReadWrite).remove(keyCopy, [errorHandler, keyCopy](const Akonadi2::Storage::Error &error) { ErrorMsg() << "Error while removing value" << error.message << keyCopy; -- cgit v1.2.3