summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2012-11-12 14:41:56 +0100
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-11-14 12:03:39 +0100
commitd919121cb7ab0655165a67759cd9c2a80a31e3ff (patch)
tree37b96142531954b2de63d3136efd6944e01dda4a /src/libs
parent5bc18bd5b6a8a91ef168325c5a97bfdb0f96b84a (diff)
Fix crash: We need the binary content throughout the whole lifetime.
In case an operation will access the resource section the binary content maps into memory, we crashed before as the BC was constructed on the stack and the mapping got destroyed during object destruction. Make it possible the read binary content from a given file, add ctor. Change-Id: I6dcd3e08fc72538deb78a7a4b831f0cd03e5a0cf Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/operationrunner.cpp23
-rw-r--r--src/libs/installer/operationrunner.h7
2 files changed, 23 insertions, 7 deletions
diff --git a/src/libs/installer/operationrunner.cpp b/src/libs/installer/operationrunner.cpp
index 26e7e6b02..c26188ce3 100644
--- a/src/libs/installer/operationrunner.cpp
+++ b/src/libs/installer/operationrunner.cpp
@@ -31,14 +31,11 @@
**************************************************************************/
#include "operationrunner.h"
-#include "binaryformat.h"
-#include "component.h"
#include "errors.h"
#include "init.h"
#include "packagemanagercore.h"
#include "utils.h"
-#include "kdupdaterupdateoperation.h"
#include "kdupdaterupdateoperationfactory.h"
#include <iostream>
@@ -62,7 +59,19 @@ using namespace QInstallerCreator;
OperationRunner::OperationRunner()
: m_core(0)
{
- QInstaller::init();
+ m_path = QCoreApplication::applicationFilePath();
+#ifdef Q_OS_MAC
+ QDir resourcePath(QFileInfo(m_path).dir());
+ resourcePath.cdUp();
+ resourcePath.cd(QLatin1String("Resources"));
+ m_path = resourcePath.filePath(QLatin1String("installer.dat"));
+#endif
+}
+
+OperationRunner::OperationRunner(const QString &path)
+ : m_core(0)
+ , m_path(path)
+{
}
OperationRunner::~OperationRunner()
@@ -73,8 +82,10 @@ OperationRunner::~OperationRunner()
bool OperationRunner::init()
{
try {
- BinaryContent content = BinaryContent::readAndRegisterFromApplicationFile();
- m_core = new PackageManagerCore(content.magicMarker(), content.performedOperations());
+ QInstaller::init();
+
+ m_bc = BinaryContent::readAndRegisterFromBinary(m_path);
+ m_core = new PackageManagerCore(m_bc.magicMarker(), m_bc.performedOperations());
} catch (const Error &e) {
std::cerr << qPrintable(e.message()) << std::endl;
return false;
diff --git a/src/libs/installer/operationrunner.h b/src/libs/installer/operationrunner.h
index 9d3056e16..32d18b35f 100644
--- a/src/libs/installer/operationrunner.h
+++ b/src/libs/installer/operationrunner.h
@@ -33,6 +33,7 @@
#ifndef OPERATIONRUNNER_H
#define OPERATIONRUNNER_H
+#include "binaryformat.h"
#include "installer_global.h"
QT_FORWARD_DECLARE_CLASS(QStringList)
@@ -44,7 +45,8 @@ class PackageManagerCore;
class INSTALLER_EXPORT OperationRunner
{
public:
- explicit OperationRunner();
+ OperationRunner();
+ explicit OperationRunner(const QString &path);
~OperationRunner();
bool init();
@@ -53,6 +55,9 @@ public:
private:
PackageManagerCore *m_core;
+
+ QString m_path;
+ BinaryContent m_bc;
};
} // namespace QInstaller