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_Q(QResourceFileEngine);
|
||||||
Q_UNUSED(flags);
|
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 max = resource.uncompressedSize();
|
||||||
qint64 end;
|
qint64 end;
|
||||||
@ -1587,14 +1590,12 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uchar *address = resource.data();
|
const uchar *address = reinterpret_cast<const uchar *>(uncompressed.constBegin());
|
||||||
if (resource.compressionAlgorithm() != QResource::NoCompression) {
|
if (!uncompressed.isNull())
|
||||||
uncompress();
|
return const_cast<uchar *>(address) + offset;
|
||||||
if (uncompressed.isNull())
|
|
||||||
return nullptr;
|
|
||||||
address = reinterpret_cast<const uchar *>(uncompressed.constData());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// resource was not compressed
|
||||||
|
address = resource.data();
|
||||||
return const_cast<uchar *>(address) + offset;
|
return const_cast<uchar *>(address) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user