diff options
author | Aurélien Gâteau <agateau@genymobile.com> | 2017-08-17 11:25:37 +0200 |
---|---|---|
committer | Aurélien Gâteau <agateau@genymobile.com> | 2017-11-03 08:23:52 +0000 |
commit | 46a7f8f47a365e27cb523241eb9cb8fa76abbca4 (patch) | |
tree | 0185a70e6548bc71f1fd629b5fd6d5ef52e312a6 | |
parent | 779002b14dc2e9e4eb22f2c2c243f3da12fa4c72 (diff) | |
download | qttools-46a7f8f47a365e27cb523241eb9cb8fa76abbca4.tar.gz |
macdeployqt sort QML modules before deploying them
Sorting QML modules makes sure a module is deployed before its sub-modules,
avoiding the problem where macdeployqt would consider a module as deployed
because one of its sub-module has already been deployed.
Task-number: QTBUG-47067
Change-Id: I0ab8dd827fcd6eea0f0573157101ceb8f1a045fc
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r-- | src/macdeployqt/shared/shared.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp index 23548236a..49dbe5426 100644 --- a/src/macdeployqt/shared/shared.cpp +++ b/src/macdeployqt/shared/shared.cpp @@ -1167,6 +1167,15 @@ void deployQmlImport(const QString &appBundlePath, const QSet<QString> &rpaths, recursiveCopyAndDeploy(appBundlePath, rpaths, importSourcePath, importDestinationPath); } +static bool importLessThan(const QVariant &v1, const QVariant &v2) +{ + QVariantMap import1 = v1.toMap(); + QVariantMap import2 = v2.toMap(); + QString path1 = import1["path"].toString(); + QString path2 = import2["path"].toString(); + return path1 < path2; +} + // Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to Contents/Resources/qml. bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs) { @@ -1228,12 +1237,15 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf bool qtQuickContolsInUse = false; // condition for QtQuick.PrivateWidgets below - // deploy each import - foreach (const QJsonValue &importValue, doc.array()) { - if (!importValue.isObject()) - continue; + // sort imports to deploy a module before its sub-modules (otherwise + // deployQmlImports can consider the module deployed if it has already + // deployed one of its sub-module) + QVariantList array = doc.array().toVariantList(); + qSort(array.begin(), array.end(), importLessThan); - QJsonObject import = importValue.toObject(); + // deploy each import + foreach (const QVariant &importValue, array) { + QVariantMap import = importValue.toMap(); QString name = import["name"].toString(); QString path = import["path"].toString(); QString type = import["type"].toString(); |