Skip to content

Commit

Permalink
macdeployqt: adjust to [[nodiscard]] QFile::open()
Browse files Browse the repository at this point in the history
The QFile::open() method becomes [[nodiscard]] in Qt 6.10.
However, macdeployqt was not adapted to this change. As a result, an
attempt to bump the Qt version fails in the CI.

This patch fixes the tool.
Amends 7466831.

Change-Id: I0dc0bc4c892f42e58d80da2407ddd83781ad8246
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
Ivan Solovev committed Dec 11, 2024
1 parent 2501170 commit 77b94a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/tools/macdeployqt/macdeployqt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ qt_internal_add_tool(${target_name}
main.cpp
DEFINES
QT_NO_FOREACH
QT_USE_NODISCARD_FILE_OPEN
LIBRARIES
${FWCoreFoundation}
)
Expand Down
21 changes: 13 additions & 8 deletions src/tools/macdeployqt/shared/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,18 @@ void patch_debugInInfoPlist(const QString &infoPlistPath)
// Older versions of qmake may have the "_debug" binary as
// the value for CFBundleExecutable. Remove it.
QFile infoPlist(infoPlistPath);
infoPlist.open(QIODevice::ReadOnly);
QByteArray contents = infoPlist.readAll();
infoPlist.close();
infoPlist.open(QIODevice::WriteOnly | QIODevice::Truncate);
contents.replace("_debug", ""); // surely there are no legit uses of "_debug" in an Info.plist
infoPlist.write(contents);
if (infoPlist.open(QIODevice::ReadOnly)) {
QByteArray contents = infoPlist.readAll();
infoPlist.close();
if (infoPlist.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
contents.replace("_debug", ""); // surely there are no legit uses of "_debug" in an Info.plist
infoPlist.write(contents);
} else {
LogError() << "failed to write Info.plist file" << infoPlistPath;
}
} else {
LogError() << "failed to read Info.plist file" << infoPlistPath;
}
}

OtoolInfo findDependencyInfo(const QString &binaryPath)
Expand Down Expand Up @@ -1233,8 +1239,7 @@ void createQtConf(const QString &appBundlePath)
return;
}

qtconf.open(QIODevice::WriteOnly);
if (qtconf.write(contents) != -1) {
if (qtconf.open(QIODevice::WriteOnly) && qtconf.write(contents) != -1) {
LogNormal() << "Created configuration file:" << fileName;
LogNormal() << "This file sets the plugin search path to" << appBundlePath + "/Contents/PlugIns";
}
Expand Down

0 comments on commit 77b94a1

Please sign in to comment.