From bde2764ab0a1bfdd253426ab466583e229be93f9 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 8 Dec 2021 19:26:29 +0100 Subject: [PATCH] Check if QML plugin has the embedded QML files before copying to the Android bundle We can detect if QML module has the embedded into the plugin QML files using the 'prefer' record from qmldir files. No need to duplicate QML files inside the android_rcc_bundle if 'prefer' record starts with ':/'. Pick-to: 6.3 Fixes: QTBUG-95984 Change-Id: Iee4f2248e3c0239c4f95a5db6e8fb3f16be636c5 Reviewed-by: Ulf Hermann --- src/tools/androiddeployqt/main.cpp | 38 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index d80fdc4398..4c79463ebf 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -2131,24 +2131,30 @@ bool scanImports(Options *options, QSet *usedDependencies) collectQmlDependency(qmldirFileInfo.absoluteFilePath()); } - QVariantList qmlFiles = - object.value(QLatin1String("components")).toArray().toVariantList(); - qmlFiles.append(object.value(QLatin1String("scripts")).toArray().toVariantList()); - bool qmlFilesMissing = false; - for (const auto &qmlFileEntry : qmlFiles) { - QFileInfo fileInfo(qmlFileEntry.toString()); - if (!fileInfo.exists()) { - qmlFilesMissing = true; - break; + QString prefer = object.value(QLatin1String("prefer")).toString(); + // If the preferred location of Qml files points to the Qt resources, this means + // that all Qml files has been embedded into plugin and we should not copy them to the + // android rcc bundle + if (!prefer.startsWith(QLatin1String(":/"))) { + QVariantList qmlFiles = + object.value(QLatin1String("components")).toArray().toVariantList(); + qmlFiles.append(object.value(QLatin1String("scripts")).toArray().toVariantList()); + bool qmlFilesMissing = false; + for (const auto &qmlFileEntry : qmlFiles) { + QFileInfo fileInfo(qmlFileEntry.toString()); + if (!fileInfo.exists()) { + qmlFilesMissing = true; + break; + } + collectQmlDependency(fileInfo.absoluteFilePath()); } - collectQmlDependency(fileInfo.absoluteFilePath()); - } - if (qmlFilesMissing) { - if (options->verbose) - fprintf(stdout, - " -- Skipping because the required qml files are missing.\n"); - continue; + if (qmlFilesMissing) { + if (options->verbose) + fprintf(stdout, + " -- Skipping because the required qml files are missing.\n"); + continue; + } } options->qtDependencies[options->currentArchitecture].append(qmlImportsDependencies);