QResource: simplify map() to rely on the uncompressed data being there
We can only call map() if we've already called open() and that will decompress the data. Pick-to: 6.6 6.5 Change-Id: I6979d02a7395405cbf23fffd17c8f1f77ca92b2b Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit bc5cd4dba8dceed808a573c6201acd9d210dc315) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
78bf5f7ccd
commit
404ac7d7f3
@ -1578,6 +1578,9 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory
|
||||
{
|
||||
Q_Q(QResourceFileEngine);
|
||||
Q_UNUSED(flags);
|
||||
Q_ASSERT_X(resource.compressionAlgorithm() == QResource::NoCompression
|
||||
|| !uncompressed.isNull(), "QFile::map()",
|
||||
"open() should have uncompressed compressed resources");
|
||||
|
||||
qint64 max = resource.uncompressedSize();
|
||||
qint64 end;
|
||||
@ -1587,14 +1590,12 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const uchar *address = resource.data();
|
||||
if (resource.compressionAlgorithm() != QResource::NoCompression) {
|
||||
uncompress();
|
||||
if (uncompressed.isNull())
|
||||
return nullptr;
|
||||
address = reinterpret_cast<const uchar *>(uncompressed.constData());
|
||||
}
|
||||
const uchar *address = reinterpret_cast<const uchar *>(uncompressed.constBegin());
|
||||
if (!uncompressed.isNull())
|
||||
return const_cast<uchar *>(address) + offset;
|
||||
|
||||
// resource was not compressed
|
||||
address = resource.data();
|
||||
return const_cast<uchar *>(address) + offset;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user