diff options
author | kh1 <karsten.heimrich@digia.com> | 2013-10-16 15:04:28 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-10-16 15:51:30 +0200 |
commit | 0f4ceb1950c18d7de27265504e104a65f2be7628 (patch) | |
tree | a4e1f245ff59cd5848410a61d5e11770cbb80ec5 /src/libs/installer/binaryformat.cpp | |
parent | 27a63dd497c25f9cc1c97b4decfacd618114521c (diff) |
Implement a way to replace the default resource.
Change-Id: I2e362d255bf2526f216cbb872bbb64d37383d229
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Reviewed-by: Michal Klocek <michal.klocek@digia.com>
Diffstat (limited to 'src/libs/installer/binaryformat.cpp')
-rw-r--r-- | src/libs/installer/binaryformat.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index fe1c61ced..081555a59 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -796,7 +796,7 @@ BinaryContentPrivate::BinaryContentPrivate(const BinaryContentPrivate &other) BinaryContentPrivate::~BinaryContentPrivate() { foreach (const QByteArray &rccData, m_resourceMappings) - QResource::unregisterResource((const uchar*)rccData.constData()); + QResource::unregisterResource((const uchar*)rccData.constData(), QLatin1String(":/metadata")); m_resourceMappings.clear(); } @@ -1138,6 +1138,27 @@ int BinaryContent::registerEmbeddedQResources() } /*! + Registers the passed file as default resource content. If the embedded resources are already mapped into + memory, it will replace the first with the new content. +*/ +void BinaryContent::registerAsDefaultQResource(const QString &path) +{ + QFile resource(path); + bool success = resource.open(QIODevice::ReadOnly); + if (success && (d->m_resourceMappings.count() > 0)) { + success = QResource::unregisterResource((const uchar*)d->m_resourceMappings.takeFirst().constData(), + QLatin1String(":/metadata")); + } + + if (success) { + d->m_resourceMappings.prepend(addResourceFromBinary(&resource, Range<qint64>::fromStartAndEnd(0, + resource.size()))); + } else { + qWarning() << QString::fromLatin1("Could not register '%1' as default resource.").arg(path); + } +} + +/*! Returns the binary component index as read from the file. */ QInstallerCreator::ComponentIndex BinaryContent::componentIndex() const |