Windeployqt: change qtModule return value to prevent invalid modules

When the change from quint64 to bitsets was originally made, the return
value of the qtModule function was not adapted. Where returning 0 was
fine for the quint64 values which started at 1, returning 0 now adds
the first module instead of adding nothing to the used/required modules

Fixes: QTBUG-111984
Pick-to: 6.5
Change-Id: Id1e2b3237a36335ec5071180b4c73f99d5eb5c8d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Timothée Keller 2023-03-21 14:40:59 +01:00
parent a215e6650a
commit a516a368c2

View File

@ -806,7 +806,7 @@ private:
DllDirectoryFileEntryFunction m_dllFilter; DllDirectoryFileEntryFunction m_dllFilter;
}; };
static quint64 qtModule(QString module, const QString &infix) static qint64 qtModule(QString module, const QString &infix)
{ {
// Match needle 'path/Qt6Core<infix><d>.dll' or 'path/libQt6Core<infix>.so.5.0' // Match needle 'path/Qt6Core<infix><d>.dll' or 'path/libQt6Core<infix>.so.5.0'
const qsizetype lastSlashPos = module.lastIndexOf(u'/'); const qsizetype lastSlashPos = module.lastIndexOf(u'/');
@ -827,7 +827,8 @@ static quint64 qtModule(QString module, const QString &infix)
return qtModule.id; return qtModule.id;
} }
} }
return 0; std::wcerr << "Warning: module " << qPrintable(module) << " could not be found\n";
return -1;
} }
// Return the path if a plugin is to be deployed // Return the path if a plugin is to be deployed
@ -855,8 +856,11 @@ static QString deployPlugin(const QString &plugin, const QDir &subDir,
QString errorMessage; QString errorMessage;
if (findDependentQtLibraries(libraryLocation, pluginPath, platform, if (findDependentQtLibraries(libraryLocation, pluginPath, platform,
&errorMessage, &dependentQtLibs)) { &errorMessage, &dependentQtLibs)) {
for (int d = 0; d < dependentQtLibs.size(); ++ d) for (int d = 0; d < dependentQtLibs.size(); ++d) {
neededModules[qtModule(dependentQtLibs.at(d), infix)] = 1; const qint64 module = qtModule(dependentQtLibs.at(d), infix);
if (module >= 0)
neededModules[module] = 1;
}
} else { } else {
std::wcerr << "Warning: Cannot determine dependencies of " std::wcerr << "Warning: Cannot determine dependencies of "
<< QDir::toNativeSeparators(pluginPath) << ": " << errorMessage << '\n'; << QDir::toNativeSeparators(pluginPath) << ": " << errorMessage << '\n';
@ -1253,7 +1257,8 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString>
// Determine application type, check Quick2 is used by looking at the // Determine application type, check Quick2 is used by looking at the
// direct dependencies (do not be fooled by QtWebKit depending on it). // direct dependencies (do not be fooled by QtWebKit depending on it).
for (int m = 0; m < dependentQtLibs.size(); ++m) { for (int m = 0; m < dependentQtLibs.size(); ++m) {
const quint64 module = qtModule(dependentQtLibs.at(m), infix); const qint64 module = qtModule(dependentQtLibs.at(m), infix);
if (module >= 0)
result.directlyUsedQtLibraries[module] = 1; result.directlyUsedQtLibraries[module] = 1;
} }
@ -1365,8 +1370,9 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString>
// QtModule enumeration (and thus controlled by flags) and others. // QtModule enumeration (and thus controlled by flags) and others.
QStringList deployedQtLibraries; QStringList deployedQtLibraries;
for (int i = 0 ; i < dependentQtLibs.size(); ++i) { for (int i = 0 ; i < dependentQtLibs.size(); ++i) {
if (const quint64 qtm = qtModule(dependentQtLibs.at(i), infix)) const qint64 module = qtModule(dependentQtLibs.at(i), infix);
result.usedQtLibraries[qtm] = 1; if (module >= 0)
result.usedQtLibraries[module] = 1;
else else
deployedQtLibraries.push_back(dependentQtLibs.at(i)); // Not represented by flag. deployedQtLibraries.push_back(dependentQtLibs.at(i)); // Not represented by flag.
} }