summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2012-11-20 15:59:59 +0100
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-11-21 10:25:14 +0100
commit46c8887c224f9653c3351eb1474ab3966c3e1215 (patch)
treed69fff6ee8b6b8b4ddbdf6d50f3f0d2786a4c6be /src/libs/installer
parent004ba0b129a701ad9bc29f2350c723641416c69f (diff)
Fix dangling resource data.
Task-number: QTIFW-168 Use QByteArray as a data container for resources to keep a reference to that data till the data is needed / the QByteArray exists. Change-Id: I2436ae2204bd1bdb834e6c8e434b2673b12c4fad Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/binaryformat.cpp12
-rw-r--r--src/libs/installer/binaryformat.h2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp
index 8410f8ca1..6b3cf88a4 100644
--- a/src/libs/installer/binaryformat.cpp
+++ b/src/libs/installer/binaryformat.cpp
@@ -733,7 +733,7 @@ int ComponentIndex::componentCount() const
\internal
Registers the resource found at \a segment within \a file into the Qt resource system.
*/
-static const uchar* addResourceFromBinary(QFile* file, const Range<qint64> &segment)
+static QByteArray addResourceFromBinary(QFile* file, const Range<qint64> &segment)
{
if (segment.length() <= 0)
return 0;
@@ -743,10 +743,10 @@ static const uchar* addResourceFromBinary(QFile* file, const Range<qint64> &segm
.arg(QString::number(segment.start()), QString::number(segment.length())));
}
- const QByteArray ba = retrieveData(file, segment.length());
- if (!QResource::registerResource((const uchar*)(ba.constData()), QLatin1String(":/metadata")))
+ 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*)(ba.constData());
+ return ba;
}
@@ -786,8 +786,8 @@ BinaryContentPrivate::BinaryContentPrivate(const BinaryContentPrivate &other)
BinaryContentPrivate::~BinaryContentPrivate()
{
- foreach (const uchar *rccData, m_resourceMappings)
- QResource::unregisterResource(rccData);
+ foreach (const QByteArray &rccData, m_resourceMappings)
+ QResource::unregisterResource((const uchar*)rccData.constData());
m_resourceMappings.clear();
}
diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h
index ae3b93006..a3284d58e 100644
--- a/src/libs/installer/binaryformat.h
+++ b/src/libs/installer/binaryformat.h
@@ -207,7 +207,7 @@ public:
QList<Operation *> m_performedOperations;
QList<QPair<QString, QString> > m_performedOperationsData;
- QVector<const uchar *> m_resourceMappings;
+ QVector<QByteArray> m_resourceMappings;
QVector<Range<qint64> > m_metadataResourceSegments;
QInstallerCreator::ComponentIndex m_componentIndex;