diff options
author | Arno Rehn <a.rehn@menlosystems.com> | 2023-09-25 13:11:58 +0200 |
---|---|---|
committer | Arno Rehn <a.rehn@menlosystems.com> | 2023-10-10 13:19:34 +0200 |
commit | a1e052a2918b6863dada64cba1a67c16762cde85 (patch) | |
tree | 51354942e0a46656fd8ba5567c2428216a86f894 /src/tools/windeployqt/main.cpp | |
parent | 3ee57b83870567d52acc00e534ef022a6d3b150e (diff) |
windeployqt: Don't copy files from unneeded QML modules
Previously, windeployqt would recurse into subdirectories when copying
QML modules, even if those subdirectories were a nested QML module that
was not needed for deployment.
Since most QML modules are nested in the QtQuick and QtQml modules, the
old code effectively always copied *all* QML modules.
This patch adds guards that prevent recursing into subdirectories if
those subdirectories represent QML modules.
These nested modules will still be deployed, but only if referenced from
the QML application (as determined by qmlimportscanner).
Fixes: QTBUG-117459
Pick-to: 6.6
Change-Id: I4c0dfc15956ff40a0e8caec3fa334df10cc92ccd
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/tools/windeployqt/main.cpp')
-rw-r--r-- | src/tools/windeployqt/main.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/tools/windeployqt/main.cpp b/src/tools/windeployqt/main.cpp index 26675b378d..71782001d1 100644 --- a/src/tools/windeployqt/main.cpp +++ b/src/tools/windeployqt/main.cpp @@ -782,13 +782,19 @@ public: SkipSources = 0x2 }; - explicit QmlDirectoryFileEntryFunction(Platform platform, DebugMatchMode debugMatchMode, unsigned flags) + explicit QmlDirectoryFileEntryFunction( + const QString &moduleSourcePath, Platform platform, DebugMatchMode debugMatchMode, unsigned flags) : m_flags(flags), m_qmlNameFilter(QmlDirectoryFileEntryFunction::qmlNameFilters(flags)) - , m_dllFilter(platform, debugMatchMode) + , m_dllFilter(platform, debugMatchMode), m_moduleSourcePath(moduleSourcePath) {} QStringList operator()(const QDir &dir) const { + if (moduleSourceDir(dir).canonicalPath() != m_moduleSourcePath) { + // If we're in a different module, return nothing. + return {}; + } + QStringList result; const QStringList &libraries = m_dllFilter(dir); for (const QString &library : libraries) { @@ -804,6 +810,17 @@ public: } private: + static QDir moduleSourceDir(const QDir &dir) + { + QDir moduleSourceDir = dir; + while (!moduleSourceDir.exists(QStringLiteral("qmldir"))) { + if (!moduleSourceDir.cdUp()) { + return {}; + } + } + return moduleSourceDir; + } + static inline QStringList qmlNameFilters(unsigned flags) { QStringList result; @@ -820,6 +837,7 @@ private: const unsigned m_flags; NameFilterFileEntryFunction m_qmlNameFilter; DllDirectoryFileEntryFunction m_dllFilter; + QString m_moduleSourcePath; }; static qint64 qtModule(QString module, const QString &infix) @@ -1539,7 +1557,8 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString> unsigned qmlDirectoryFileFlags = 0; if (options.deployPdb) qmlDirectoryFileFlags |= QmlDirectoryFileEntryFunction::DeployPdb; - if (!updateFile(module.sourcePath, QmlDirectoryFileEntryFunction(options.platform, + if (!updateFile(module.sourcePath, QmlDirectoryFileEntryFunction(module.sourcePath, + options.platform, debugMatchMode, qmlDirectoryFileFlags), installPath, updateFileFlags, options.json, errorMessage)) { |