summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-06-26 16:10:24 +0200
committerKai Koehne <kai.koehne@digia.com>2014-07-02 14:07:08 +0200
commit71868e96bfd29368b55ef1111328ac9b9f91e1a4 (patch)
tree565bce558aef55db733e5615dafbcf50a95bcfe1 /tools
parent941d79e401c7795382240684b6dd53e774a34108 (diff)
Fix broken tools after switching to QFileDevice.
Follow up on 924ebcdbc9b9e590a5f0905941e2d05ac34d4be2 (Part 1). Get rid of KDSaveFile, reuse QTemporaryFile. After changing KDSaveFile to inherit from QFileDevice, it turns out to be not working properly anymore and crashing e.g. binarycreator while using it. To save fixing it we just switch to QTemporaryFile. Change-Id: I785a04db91b431f5e122f193ecf2ef3c54e34b1c Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/binarycreator/binarycreator.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp
index 97cd1c5b9..cbb8fddc7 100644
--- a/tools/binarycreator/binarycreator.cpp
+++ b/tools/binarycreator/binarycreator.cpp
@@ -51,8 +51,6 @@
#include <settings.h>
#include <utils.h>
-#include <kdsavefile.h>
-
#include <QtCore/QDirIterator>
#include <QtCore/QProcess>
#include <QtCore/QSettings>
@@ -257,27 +255,35 @@ static int assemble(Input input, const QInstaller::Settings &settings)
}
#endif
+ QTemporaryFile out;
+ QString targetName = input.outputPath;
#ifdef Q_OS_MAC
QDir resourcePath(QFileInfo(input.outputPath).dir());
resourcePath.cdUp();
resourcePath.cd(QLatin1String("Resources"));
- KDSaveFile out(resourcePath.filePath(QLatin1String("installer.dat")));
-#else
- KDSaveFile out(input.outputPath);
+ targetName = resourcePath.filePath(QLatin1String("installer.dat"));
#endif
+
+ {
+ QFile target(targetName);
+ if (target.exists() && !target.remove()) {
+ qCritical("Could not remove target %s: %s", qPrintable(target.fileName()),
+ qPrintable(target.errorString()));
+ QFile::remove(tempFile);
+ return EXIT_FAILURE;
+ }
+ }
+
try {
-#ifdef Q_OS_MAC
QInstaller::openForWrite(&out);
-
QFile exe(input.installerExePath);
+
+#ifdef Q_OS_MAC
if (!exe.copy(input.outputPath)) {
- throw Error(QString::fromLatin1("Could not copy %1 to %2: %3").arg(exe.fileName(), input.outputPath,
- exe.errorString()));
+ throw Error(QString::fromLatin1("Could not copy %1 to %2: %3").arg(exe.fileName(),
+ input.outputPath, exe.errorString()));
}
#else
- QInstaller::openForWrite(&out);
-
- QFile exe(input.installerExePath);
QInstaller::openForRead(&exe);
QInstaller::appendData(&out, &exe, exe.size());
#endif
@@ -334,12 +340,14 @@ static int assemble(Input input, const QInstaller::Settings &settings)
return EXIT_FAILURE;
}
- if (!out.commit(KDSaveFile::OverwriteExistingFile)) {
- qCritical("Could not write installer to %s: %s", qPrintable(out.fileName()),
- qPrintable(out.errorString()));
+ if (!out.rename(targetName)) {
+ qCritical("Could not write installer to %s: %s", targetName.toUtf8().constData(),
+ out.errorString().toUtf8().constData());
QFile::remove(tempFile);
return EXIT_FAILURE;
}
+ out.setAutoRemove(false);
+
#ifndef Q_OS_WIN
chmod755(out.fileName());
#endif