[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
This commit is contained in:
stkrwork 2017-09-19 03:31:53 +02:00 committed by wing328
parent f3c41e866c
commit 5443c0a94c
2 changed files with 4 additions and 1 deletions

View File

@ -317,6 +317,9 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
} else if (p instanceof MapProperty) { } else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p; MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties()); String inner = getSwaggerType(ap.getAdditionalProperties());
if (!languageSpecificPrimitives.contains(inner)) {
inner += "*";
}
return "new QMap<QString, " + inner + ">()"; return "new QMap<QString, " + inner + ">()";
} else if (p instanceof ArrayProperty) { } else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p; ArrayProperty ap = (ArrayProperty) p;

View File

@ -37,7 +37,7 @@ void
{{classname}}::cleanup() { {{classname}}::cleanup() {
{{#vars}}{{#complexType}} {{#vars}}{{#complexType}}
if({{name}} != nullptr) { if({{name}} != nullptr) {
{{#isContainer}}QList<{{complexType}}*>* arr = {{name}}; {{#isContainer}}{{#isListContainer}}QList<{{complexType}}*>* arr = {{name}};{{/isListContainer}}{{#isMapContainer}}QMap<QString, {{complexType}}*>* arr = {{name}};{{/isMapContainer}}
foreach({{complexType}}* o, *arr) { foreach({{complexType}}* o, *arr) {
delete o; delete o;
} }