From b035546f9976a984474a45bb61aa7767f88a7bd3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 7 May 2018 16:11:18 +0200 Subject: Never allocate KJob subclasses on the stack The delete themselves. --- examples/caldavresource/tests/caldavtest.cpp | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/caldavresource/tests/caldavtest.cpp b/examples/caldavresource/tests/caldavtest.cpp index aadd580..b9886fa 100644 --- a/examples/caldavresource/tests/caldavtest.cpp +++ b/examples/caldavresource/tests/caldavtest.cpp @@ -268,18 +268,18 @@ private slots: url.setUserName(username); url.setPassword(password); KDAV2::DavUrl davurl(url, KDAV2::CalDav); - KDAV2::DavCollectionsFetchJob collectionsJob(davurl); - collectionsJob.exec(); - Q_ASSERT(collectionsJob.error() == 0); - return collectionsJob.collections()[0]; + auto collectionsJob = new KDAV2::DavCollectionsFetchJob(davurl); + collectionsJob->exec(); + Q_ASSERT(collectionsJob->error() == 0); + return collectionsJob->collections()[0]; })(); auto itemList = ([&collection]() -> KDAV2::DavItem::List { auto cache = std::make_shared(); - KDAV2::DavItemsListJob itemsListJob(collection.url(), cache); - itemsListJob.exec(); - Q_ASSERT(itemsListJob.error() == 0); - return itemsListJob.items(); + auto itemsListJob = new KDAV2::DavItemsListJob(collection.url(), cache); + itemsListJob->exec(); + Q_ASSERT(itemsListJob->error() == 0); + return itemsListJob->items(); })(); auto hollowDavItemIt = std::find_if(itemList.begin(), itemList.end(), [this](const KDAV2::DavItem &item) { @@ -288,10 +288,10 @@ private slots: auto davitem = ([this, &collection, &hollowDavItemIt]() -> KDAV2::DavItem { QString itemUrl = collection.url().url().toEncoded() + addedEventUid; - KDAV2::DavItemFetchJob itemFetchJob(*hollowDavItemIt); - itemFetchJob.exec(); - Q_ASSERT(itemFetchJob.error() == 0); - return itemFetchJob.item(); + auto itemFetchJob = new KDAV2::DavItemFetchJob (*hollowDavItemIt); + itemFetchJob->exec(); + Q_ASSERT(itemFetchJob->error() == 0); + return itemFetchJob->item(); })(); auto incidence = KCalCore::ICalFormat().readIncidence(davitem.data()); @@ -302,9 +302,9 @@ private slots: auto newical = KCalCore::ICalFormat().toICalString(calevent); davitem.setData(newical.toUtf8()); - KDAV2::DavItemModifyJob itemModifyJob(davitem); - itemModifyJob.exec(); - QVERIFY2(itemModifyJob.error() == 0, "Cannot modify item"); + auto itemModifyJob = new KDAV2::DavItemModifyJob(davitem); + itemModifyJob->exec(); + QVERIFY2(itemModifyJob->error() == 0, "Cannot modify item"); } // Try to change the item with sink -- cgit v1.2.3