diff --git a/src/akonadi/akonadicachingstorage.h b/src/akonadi/akonadicachingstorage.h --- a/src/akonadi/akonadicachingstorage.h +++ b/src/akonadi/akonadicachingstorage.h @@ -49,7 +49,7 @@ KJob *updateCollection(Collection collection, QObject *parent) override; KJob *removeCollection(Collection collection, QObject *parent) override; - KJob *createTransaction() override; + KJob *createTransaction(QObject *parent) override; CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) override; ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) override; diff --git a/src/akonadi/akonadicachingstorage.cpp b/src/akonadi/akonadicachingstorage.cpp --- a/src/akonadi/akonadicachingstorage.cpp +++ b/src/akonadi/akonadicachingstorage.cpp @@ -358,9 +358,9 @@ return m_storage->removeCollection(collection, parent); } -KJob *CachingStorage::createTransaction() +KJob *CachingStorage::createTransaction(QObject *parent) { - return m_storage->createTransaction(); + return m_storage->createTransaction(parent); } CollectionFetchJobInterface *CachingStorage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth) diff --git a/src/akonadi/akonadiprojectrepository.cpp b/src/akonadi/akonadiprojectrepository.cpp --- a/src/akonadi/akonadiprojectrepository.cpp +++ b/src/akonadi/akonadiprojectrepository.cpp @@ -96,7 +96,7 @@ Item::List childItems = m_serializer->filterDescendantItems(fetchChildrenItemJob->items(), childItem); - auto transaction = m_storage->createTransaction(); + auto transaction = m_storage->createTransaction(this); m_storage->updateItem(childItem, transaction); childItems.push_front(childItem); m_storage->moveItems(childItems, parentItem.parentCollection(), transaction); diff --git a/src/akonadi/akonadistorage.h b/src/akonadi/akonadistorage.h --- a/src/akonadi/akonadistorage.h +++ b/src/akonadi/akonadistorage.h @@ -50,7 +50,7 @@ KJob *updateCollection(Collection collection, QObject *parent) override; KJob *removeCollection(Collection collection, QObject *parent) override; - KJob *createTransaction() override; + KJob *createTransaction(QObject *parent) override; CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) override; ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) override; diff --git a/src/akonadi/akonadistorage.cpp b/src/akonadi/akonadistorage.cpp --- a/src/akonadi/akonadistorage.cpp +++ b/src/akonadi/akonadistorage.cpp @@ -188,9 +188,9 @@ return new CollectionDeleteJob(collection, parent); } -KJob *Storage::createTransaction() +KJob *Storage::createTransaction(QObject *parent) { - return new TransactionSequence(); + return new TransactionSequence(parent); } CollectionFetchJobInterface *Storage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth) diff --git a/src/akonadi/akonadistorageinterface.h b/src/akonadi/akonadistorageinterface.h --- a/src/akonadi/akonadistorageinterface.h +++ b/src/akonadi/akonadistorageinterface.h @@ -65,7 +65,7 @@ virtual KJob *updateCollection(Collection collection, QObject *parent) = 0; virtual KJob *removeCollection(Collection collection, QObject *parent) = 0; - virtual KJob *createTransaction() = 0; + virtual KJob *createTransaction(QObject *parent) = 0; virtual CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) = 0; virtual ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) = 0; diff --git a/src/akonadi/akonaditaskrepository.cpp b/src/akonadi/akonaditaskrepository.cpp --- a/src/akonadi/akonaditaskrepository.cpp +++ b/src/akonadi/akonaditaskrepository.cpp @@ -239,7 +239,7 @@ Item::List childItems = m_serializer->filterDescendantItems(fetchChildrenItemJob->items(), childItem); - auto transaction = m_storage->createTransaction(); + auto transaction = m_storage->createTransaction(this); m_storage->updateItem(childItem, transaction); childItems.push_front(childItem); m_storage->moveItems(childItems, parentItem.parentCollection(), transaction); diff --git a/tests/testlib/akonadifakestorage.h b/tests/testlib/akonadifakestorage.h --- a/tests/testlib/akonadifakestorage.h +++ b/tests/testlib/akonadifakestorage.h @@ -48,7 +48,7 @@ KJob *updateCollection(Akonadi::Collection collection, QObject *parent) override; KJob *removeCollection(Akonadi::Collection collection, QObject *parent) override; - KJob *createTransaction() override; + KJob *createTransaction(QObject *parent) override; Akonadi::CollectionFetchJobInterface *fetchCollections(Akonadi::Collection collection, FetchDepth depth) override; Akonadi::ItemFetchJobInterface *fetchItems(Akonadi::Collection collection, QObject *parent) override; diff --git a/tests/testlib/akonadifakestorage.cpp b/tests/testlib/akonadifakestorage.cpp --- a/tests/testlib/akonadifakestorage.cpp +++ b/tests/testlib/akonadifakestorage.cpp @@ -37,8 +37,8 @@ { Q_OBJECT public: - explicit AkonadiFakeTransaction() - : FakeJob(), + explicit AkonadiFakeTransaction(QObject *parent = nullptr) + : FakeJob(parent), m_nextIdx(0) { } @@ -303,9 +303,9 @@ return job; } -KJob *AkonadiFakeStorage::createTransaction() +KJob *AkonadiFakeStorage::createTransaction(QObject *parent) { - auto job = new AkonadiFakeTransaction; + auto job = new AkonadiFakeTransaction(parent); Utils::JobHandler::install(job, noop); return job; } diff --git a/tests/testlib/akonadistoragetestbase.cpp b/tests/testlib/akonadistoragetestbase.cpp --- a/tests/testlib/akonadistoragetestbase.cpp +++ b/tests/testlib/akonadistoragetestbase.cpp @@ -471,7 +471,7 @@ todo = item2.payload(); todo->setSummary(QStringLiteral("Buy chocolate")); - auto transaction = storage->createTransaction(); + auto transaction = storage->createTransaction(nullptr); storage->updateItem(item1, transaction); storage->updateItem(item3, transaction); // this job should fail storage->updateItem(item2, transaction); diff --git a/tests/units/akonadi/akonadiprojectrepositorytest.cpp b/tests/units/akonadi/akonadiprojectrepositorytest.cpp --- a/tests/units/akonadi/akonadiprojectrepositorytest.cpp +++ b/tests/units/akonadi/akonadiprojectrepositorytest.cpp @@ -247,7 +247,7 @@ if (parentItem.parentCollection().id() != childItem.parentCollection().id()) { storageMock(&Akonadi::StorageInterface::fetchItems).when(childItem.parentCollection(), repository.get()) .thenReturn(itemFetchJob3); - storageMock(&Akonadi::StorageInterface::createTransaction).when().thenReturn(transactionJob); + storageMock(&Akonadi::StorageInterface::createTransaction).when(repository.get()).thenReturn(transactionJob); storageMock(&Akonadi::StorageInterface::updateItem).when(childItem, transactionJob) .thenReturn(itemModifyJob); storageMock(&Akonadi::StorageInterface::moveItems).when(movedList, parentItem.parentCollection(), transactionJob) @@ -278,7 +278,7 @@ if (execParentJob) { if (parentItem.parentCollection().id() != childItem.parentCollection().id()) { QVERIFY(storageMock(&Akonadi::StorageInterface::fetchItems).when(childItem.parentCollection(), repository.get()).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::createTransaction).when().thenReturn(transactionJob).exactly(1)); + QVERIFY(storageMock(&Akonadi::StorageInterface::createTransaction).when(repository.get()).thenReturn(transactionJob).exactly(1)); QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(childItem, transactionJob).exactly(1)); QVERIFY(storageMock(&Akonadi::StorageInterface::moveItems).when(movedList, parentItem.parentCollection(), transactionJob).exactly(1)); } else { diff --git a/tests/units/akonadi/akonaditaskrepositorytest.cpp b/tests/units/akonadi/akonaditaskrepositorytest.cpp --- a/tests/units/akonadi/akonaditaskrepositorytest.cpp +++ b/tests/units/akonadi/akonaditaskrepositorytest.cpp @@ -590,7 +590,7 @@ if (parentItem.parentCollection().id() != childItem.parentCollection().id()) { storageMock(&Akonadi::StorageInterface::fetchItems).when(childItem.parentCollection(), repository.get()) .thenReturn(itemFetchJob3); - storageMock(&Akonadi::StorageInterface::createTransaction).when().thenReturn(transactionJob); + storageMock(&Akonadi::StorageInterface::createTransaction).when(repository.get()).thenReturn(transactionJob); storageMock(&Akonadi::StorageInterface::updateItem).when(childItem, transactionJob) .thenReturn(itemModifyJob); storageMock(&Akonadi::StorageInterface::moveItems).when(movedList, parentItem.parentCollection(), transactionJob) @@ -632,7 +632,7 @@ else { //QVERIFY(serializerMock(&Akonadi::SerializerInterface::filterDescendantItems).when(list, childItem).exactly(1)); QVERIFY(storageMock(&Akonadi::StorageInterface::fetchItems).when(childItem.parentCollection(), repository.get()).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::createTransaction).when().thenReturn(transactionJob).exactly(1)); + QVERIFY(storageMock(&Akonadi::StorageInterface::createTransaction).when(repository.get()).thenReturn(transactionJob).exactly(1)); QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(childItem, transactionJob).exactly(1)); QVERIFY(storageMock(&Akonadi::StorageInterface::moveItems).when(movedList, parentItem.parentCollection(), transactionJob).exactly(1)); }