diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-05-17 13:54:01 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-05-17 18:53:21 +0200 |
commit | a4cb47a8231c08783c5f89aafb54548c10fd6f78 (patch) | |
tree | fefa6cad948a51b8427634753ccdb79019811b39 | |
parent | 2da9e38f7efcb6ccf726eff2f570dd9c8d517483 (diff) | |
download | qtactiveqt-a4cb47a8231c08783c5f89aafb54548c10fd6f78.tar.gz |
dumpcpp: Modernize the generated code
Use nullptr and reinterpret_cast.
Remove unused qax_pointer variable.
Task-number: QTBUG-100145
Pick-to: 6.3
Change-Id: Icfe7cb5365b4679846bcd6bdd5cc478685910a34
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r-- | tools/dumpcpp/main.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp index 162c6c6..3142265 100644 --- a/tools/dumpcpp/main.cpp +++ b/tools/dumpcpp/main.cpp @@ -327,7 +327,6 @@ void generateClassDecl(QTextStream &out, const QMetaObject *mo, if (qax_qualified_usertypes.contains(simplePropType)) { if (foreignNamespace) out << "#ifdef QAX_DUMPCPP_" << propertyType.left(propertyType.indexOf("::")).toUpper() << "_H" << Qt::endl; - out << indent << " " << propertyType << " qax_pointer = 0;" << Qt::endl; QByteArray simplePropTypeWithNamespace = propertyType; simplePropTypeWithNamespace.replace('*', ""); out << indent << " qRegisterMetaType<" << propertyType << ">(\"" << property.typeName() << "\");" << Qt::endl; @@ -335,20 +334,21 @@ void generateClassDecl(QTextStream &out, const QMetaObject *mo, } out << indent << " QVariant qax_result = property(\"" << propertyName << "\");" << Qt::endl; if (propertyType.length() && propertyType.at(propertyType.length()-1) == '*') - out << indent << " if (!qax_result.constData()) return 0;" << Qt::endl; - out << indent << " Q_ASSERT(qax_result.isValid());" << Qt::endl; + out << indent << " if (qax_result.constData() == nullptr)\n" + << indent << " return nullptr;\n" + << indent << " Q_ASSERT(qax_result.isValid());" << Qt::endl; if (qax_qualified_usertypes.contains(simplePropType)) { simplePropType = propertyType; simplePropType.replace('*', ""); - out << indent << " return *(" << propertyType << "*)qax_result.constData();" << Qt::endl; + out << indent << " return *reinterpret_cast<" << propertyType << "*>(qax_result.data());\n"; if (foreignNamespace) { out << "#else" << Qt::endl; - out << indent << " return 0; // foreign namespace not included" << Qt::endl; + out << indent << " return nullptr; // foreign namespace not included" << Qt::endl; out << "#endif" << Qt::endl; } } else { - out << indent << " return *(" << propertyType << "*)qax_result.constData();" << Qt::endl; + out << indent << " return *reinterpret_cast<" << propertyType << "*>(qax_result.data());\n"; } out << indent << '}' << Qt::endl; } else { |