summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/binaryformat.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2012-11-13 09:44:52 +0100
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-11-14 12:02:21 +0100
commit5bc18bd5b6a8a91ef168325c5a97bfdb0f96b84a (patch)
tree5b2101470529f62adc694e40a3bb3512cdda2b7a /src/libs/installer/binaryformat.cpp
parentcd40c7dc73112264689ecb125956abdbe2b93353 (diff)
Add empty ctor, copy ctor and remove superfluous dtor...
Remove superfluous static resource vector. Check for possible null access. Change-Id: I92f1f65a9309d8f99c479b66a03b2e3000ac121c Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs/installer/binaryformat.cpp')
-rw-r--r--src/libs/installer/binaryformat.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp
index 26e2c861f..b3cecc7fb 100644
--- a/src/libs/installer/binaryformat.cpp
+++ b/src/libs/installer/binaryformat.cpp
@@ -727,7 +727,6 @@ int ComponentIndex::componentCount() const
}
-static QVector<QByteArray> sResourceVec;
/*!
\internal
Registers the resource found at \a segment within \a file into the Qt resource system.
@@ -741,21 +740,27 @@ static const uchar* addResourceFromBinary(QFile* file, const Range<qint64> &segm
throw Error(QObject::tr("Could not seek to in-binary resource. (offset: %1, length: %2)")
.arg(QString::number(segment.start()), QString::number(segment.length())));
}
- sResourceVec.append(retrieveData(file, segment.length()));
- if (!QResource::registerResource((const uchar*)(sResourceVec.last().constData()),
- QLatin1String(":/metadata"))) {
+ const QByteArray ba = retrieveData(file, segment.length());
+ if (!QResource::registerResource((const uchar*)(ba.constData()), QLatin1String(":/metadata")))
throw Error(QObject::tr("Could not register in-binary resource."));
- }
- return (const uchar*)(sResourceVec.last().constData());
+ return (const uchar*)(ba.constData());
}
// -- BinaryContentPrivate
+BinaryContentPrivate::BinaryContentPrivate()
+ : m_magicMarker(Q_INT64_C(0))
+ , m_dataBlockStart(Q_INT64_C(0))
+ , m_appBinary(0)
+ , m_binaryDataFile(0)
+ , m_binaryFormatEngineHandler(m_componentIndex)
+{
+}
BinaryContentPrivate::BinaryContentPrivate(const QString &path)
- : m_magicMarker(0)
- , m_dataBlockStart(0)
+ : m_magicMarker(Q_INT64_C(0))
+ , m_dataBlockStart(Q_INT64_C(0))
, m_appBinary(new QFile(path))
, m_binaryDataFile(0)
, m_binaryFormatEngineHandler(m_componentIndex)
@@ -781,19 +786,24 @@ BinaryContentPrivate::~BinaryContentPrivate()
{
foreach (const uchar *rccData, m_resourceMappings)
QResource::unregisterResource(rccData);
- sResourceVec.clear();
m_resourceMappings.clear();
}
// -- BinaryContent
+BinaryContent::BinaryContent()
+ : d(new BinaryContentPrivate)
+{
+}
+
BinaryContent::BinaryContent(const QString &path)
: d(new BinaryContentPrivate(path))
{
}
-BinaryContent::~BinaryContent()
+BinaryContent::BinaryContent(const BinaryContent &rhs)
+ : d(rhs.d)
{
}
@@ -826,7 +836,7 @@ BinaryContent BinaryContent::readAndRegisterFromBinary(const QString &path)
*/
BinaryContent BinaryContent::readFromApplicationFile()
{
- return BinaryContent::readFromBinary(QCoreApplication::applicationFilePath());;
+ return BinaryContent::readFromBinary(QCoreApplication::applicationFilePath());
}
/*!
@@ -1091,7 +1101,7 @@ int BinaryContent::registerEmbeddedQResources()
const bool hasBinaryDataFile = !d->m_binaryDataFile.isNull();
QFile *const data = hasBinaryDataFile ? d->m_binaryDataFile.data() : d->m_appBinary.data();
- if (!data->isOpen() && !data->open(QIODevice::ReadOnly)) {
+ if (data != 0 && !data->isOpen() && !data->open(QIODevice::ReadOnly)) {
throw Error(QObject::tr("Could not open binary %1: %2").arg(data->fileName(),
data->errorString()));
}