From 7fbf01bf07e4a3aefe18bfe63c1aacf0b6c0685c Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Fri, 15 Apr 2022 15:44:13 +0300 Subject: [PATCH] Android: remove the old copy of gradle.properties after reading it The file is going to be remove anyways in the next build, so just delete it once we're done with it, this also makes the build folder doesn't have files that are not needed. Pick-to: 6.2 6.3 5.15 Change-Id: I948f028e9151b38a3ccc1ec628239ac91397e0d0 Reviewed-by: Ivan Solovev --- src/tools/androiddeployqt/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 6067b0472f2..f42e3bd4a90 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -2602,15 +2602,16 @@ static GradleProperties readGradleProperties(const QString &path) static bool mergeGradleProperties(const QString &path, GradleProperties properties) { - QFile::remove(path + u'~'); - QFile::rename(path, path + u'~'); + const QString oldPathStr = path + u'~'; + QFile::remove(oldPathStr); + QFile::rename(path, oldPathStr); QFile file(path); if (!file.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { fprintf(stderr, "Can't open file: %s for writing\n", qPrintable(file.fileName())); return false; } - QFile oldFile(path + u'~'); + QFile oldFile(oldPathStr); if (oldFile.open(QIODevice::ReadOnly)) { while (!oldFile.atEnd()) { QByteArray line(oldFile.readLine()); @@ -2626,6 +2627,7 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti file.write(line); } oldFile.close(); + QFile::remove(oldPathStr); } for (GradleProperties::const_iterator it = properties.begin(); it != properties.end(); ++it)