From 2aaafce90387d875a05dfaf604dec66453a9a176 Mon Sep 17 00:00:00 2001 From: Soheil Armin Date: Wed, 26 Jun 2024 11:52:20 +0300 Subject: [PATCH] Android: Fix duplicate class names when generating QML to Java code Whe the QT_ANDROID_GENERATE_JAVA_QML_COMPONENTS flag is present the AndroidDeployQt generates nested classes with the same name as target and QML module names. When the target name is the same as the QML module name, the code gets generated successfuly but will fail at compile-time in the target user project. With this fix, we detect such cases and fail early, providing a proper output message Fixes: QTBUG-125160 Change-Id: I6303d76bc437f7eee806e4429bef81b5fbeb1e27 Reviewed-by: Rami Potinkara Reviewed-by: Fabian Kosmale (cherry picked from commit abfeb4542c9107fa40511209d25bc7d0b5db1a8c) Reviewed-by: Qt Cherry-pick Bot --- src/tools/androiddeployqt/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index f4c96edc55d..c91f9297005 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -3705,6 +3705,14 @@ int generateJavaQmlComponents(const Options &options) const QString moduleClassname = moduleInfo.moduleName[0].toUpper() + moduleInfo.moduleName.last(moduleInfo.moduleName.size() - 1); + if (moduleInfo.moduleName == libName) { + fprintf(stderr, + "A QML module name (%s) cannot be the same as the target name when building " + "with QT_ANDROID_GENERATE_JAVA_QML_COMPONENTS flag.\n", + qPrintable(moduleInfo.moduleName)); + return false; + } + int indentBase = 4; if (leafEqualsLibname) { indentBase = 0;