From 024f46814cd7071841c08a4363fa73c7d26a2aac Mon Sep 17 00:00:00 2001 From: Martin Delille Date: Sat, 17 Aug 2019 22:19:16 +0200 Subject: [PATCH] cpp-qt5-client: fix memory leak in api-body (#3661) --- .../resources/cpp-qt5-client/api-body.mustache | 2 +- .../client/petstore/cpp-qt5/client/OAIPetApi.cpp | 16 ++++++++-------- .../petstore/cpp-qt5/client/OAIStoreApi.cpp | 8 ++++---- .../petstore/cpp-qt5/client/OAIUserApi.cpp | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache index 5777507ec97..184e1dd20a3 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache @@ -102,7 +102,7 @@ void } } {{/collectionFormat}}{{/queryParams}} - {{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(); + {{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this); worker->setTimeOut(timeout); {{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}"); {{#formParams}} diff --git a/samples/client/petstore/cpp-qt5/client/OAIPetApi.cpp b/samples/client/petstore/cpp-qt5/client/OAIPetApi.cpp index 1341a73c3b9..9b491dc5921 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIPetApi.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIPetApi.cpp @@ -56,7 +56,7 @@ OAIPetApi::addPet(const OAIPet& body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); @@ -108,7 +108,7 @@ OAIPetApi::deletePet(const qint64& pet_id, const QString& api_key) { pet_idPathParam.append("petId").append("}"); fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(pet_id))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "DELETE"); @@ -196,7 +196,7 @@ OAIPetApi::findPetsByStatus(const QList& status) { } } - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -291,7 +291,7 @@ OAIPetApi::findPetsByTags(const QList& tags) { } } - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -349,7 +349,7 @@ OAIPetApi::getPetById(const qint64& pet_id) { pet_idPathParam.append("petId").append("}"); fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(pet_id))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -395,7 +395,7 @@ OAIPetApi::updatePet(const OAIPet& body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "PUT"); @@ -447,7 +447,7 @@ OAIPetApi::updatePetWithForm(const qint64& pet_id, const QString& name, const QS pet_idPathParam.append("petId").append("}"); fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(pet_id))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); if (name != nullptr) { @@ -501,7 +501,7 @@ OAIPetApi::uploadFile(const qint64& pet_id, const QString& additional_metadata, pet_idPathParam.append("petId").append("}"); fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(pet_id))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); if (additional_metadata != nullptr) { diff --git a/samples/client/petstore/cpp-qt5/client/OAIStoreApi.cpp b/samples/client/petstore/cpp-qt5/client/OAIStoreApi.cpp index 7b2e37f635b..cb141576b20 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIStoreApi.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIStoreApi.cpp @@ -59,7 +59,7 @@ OAIStoreApi::deleteOrder(const QString& order_id) { order_idPathParam.append("orderId").append("}"); fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(order_id))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "DELETE"); @@ -104,7 +104,7 @@ OAIStoreApi::getInventory() { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/inventory"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -162,7 +162,7 @@ OAIStoreApi::getOrderById(const qint64& order_id) { order_idPathParam.append("orderId").append("}"); fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(order_id))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -208,7 +208,7 @@ OAIStoreApi::placeOrder(const OAIOrder& body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/order"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); diff --git a/samples/client/petstore/cpp-qt5/client/OAIUserApi.cpp b/samples/client/petstore/cpp-qt5/client/OAIUserApi.cpp index 57556eab788..353e77c8981 100644 --- a/samples/client/petstore/cpp-qt5/client/OAIUserApi.cpp +++ b/samples/client/petstore/cpp-qt5/client/OAIUserApi.cpp @@ -56,7 +56,7 @@ OAIUserApi::createUser(const OAIUser& body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); @@ -105,7 +105,7 @@ OAIUserApi::createUsersWithArrayInput(const QList& body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/createWithArray"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); @@ -155,7 +155,7 @@ OAIUserApi::createUsersWithListInput(const QList& body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/createWithList"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "POST"); @@ -208,7 +208,7 @@ OAIUserApi::deleteUser(const QString& username) { usernamePathParam.append("username").append("}"); fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(username))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "DELETE"); @@ -256,7 +256,7 @@ OAIUserApi::getUserByName(const QString& username) { usernamePathParam.append("username").append("}"); fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(username))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -318,7 +318,7 @@ OAIUserApi::loginUser(const QString& username, const QString& password) { .append("=") .append(QUrl::toPercentEncoding(::OpenAPI::toStringValue(password))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -365,7 +365,7 @@ OAIUserApi::logoutUser() { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/logout"); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "GET"); @@ -413,7 +413,7 @@ OAIUserApi::updateUser(const QString& username, const OAIUser& body) { usernamePathParam.append("username").append("}"); fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::OpenAPI::toStringValue(username))); - OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(); + OAIHttpRequestWorker *worker = new OAIHttpRequestWorker(this); worker->setTimeOut(timeout); OAIHttpRequestInput input(fullPath, "PUT");