QPdfEngine: port from raw zlib to qCompress()

Hotfix for disappearing zlib symbols caused by QTBUG-104972
and QTBUG-106542 fixes, to be merged later on.

Pick-to: 6.4 6.3 6.2
Change-Id: I21e0bf13c866fa7bb45c7587c81e7fddddad90f9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Marc Mutz 2022-09-20 12:21:12 +02:00
parent e81cba0cd3
commit 6fdd986bd9

View File

@ -2280,16 +2280,15 @@ int QPdfEnginePrivate::writeCompressed(const char *src, int len)
{
#ifndef QT_NO_COMPRESS
if (do_compress) {
uLongf destLen = len + len/100 + 13; // zlib requirement
Bytef* dest = new Bytef[destLen];
if (Z_OK == ::compress(dest, &destLen, (const Bytef*) src, (uLongf)len)) {
stream->writeRawData((const char*)dest, destLen);
const QByteArray data = qCompress(reinterpret_cast<const uchar *>(src), len);
constexpr qsizetype HeaderSize = 4;
if (!data.isNull()) {
stream->writeRawData(data.data() + HeaderSize, data.size() - HeaderSize);
len = data.size() - HeaderSize;
} else {
qWarning("QPdfStream::writeCompressed: Error in compress()");
destLen = 0;
len = 0;
}
delete [] dest;
len = destLen;
} else
#endif
{