From 5443c0a94c67e84fe98aa642a16b9a56c4c1624a Mon Sep 17 00:00:00 2001 From: stkrwork Date: Tue, 19 Sep 2017 03:31:53 +0200 Subject: [PATCH] [QT5][CPP] Fixing issue with maps in models (#6479) * [QT5][CPP] Fixing issue with maps in models - Adjusted init function to init map correctly - Adjusted cleanup function to cleanup maps correctly * Fixed formatting for samples --- .../java/io/swagger/codegen/languages/Qt5CPPGenerator.java | 3 +++ .../src/main/resources/qt5cpp/model-body.mustache | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java index a2a7c9d559d..378cfad99e3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java @@ -317,6 +317,9 @@ public String toDefaultValue(Property p) { } else if (p instanceof MapProperty) { MapProperty ap = (MapProperty) p; String inner = getSwaggerType(ap.getAdditionalProperties()); + if (!languageSpecificPrimitives.contains(inner)) { + inner += "*"; + } return "new QMap()"; } else if (p instanceof ArrayProperty) { ArrayProperty ap = (ArrayProperty) p; diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache index ba23d2e61f3..14c15270042 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache @@ -37,7 +37,7 @@ void {{classname}}::cleanup() { {{#vars}}{{#complexType}} if({{name}} != nullptr) { - {{#isContainer}}QList<{{complexType}}*>* arr = {{name}}; + {{#isContainer}}{{#isListContainer}}QList<{{complexType}}*>* arr = {{name}};{{/isListContainer}}{{#isMapContainer}}QMap* arr = {{name}};{{/isMapContainer}} foreach({{complexType}}* o, *arr) { delete o; }