QWindowsMime: Fix loading of CF_DIB (non-v5) followup

5b7422f74d73822aeab76163811ea1fcaafabc12 fixed falling back to CF_DIB
when CF_DIBV5 is not provided, but the way the logic was written
depended on that typo to load synthesized CF_DIBV5. This change restores
that functionality and simplifies the logic.

Pick-to: 6.7 6.7.2 6.5
Change-Id: Icffbe8d969a47b5337701e13b35ce426e4d32166
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 5eb7141788ae3c0051b9f9c49870c88e209e71b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Viktor Arvidsson 2024-06-07 17:07:56 +02:00 committed by Qt Cherry-pick Bot
parent 690c2f2d60
commit 3d28089f9a

View File

@ -923,16 +923,8 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject *
const bool canGetDibV5 = canGetData(CF_DIBV5, pDataObj);
const bool hasOrigDibV5 = canGetDibV5 ? hasOriginalDIBV5(pDataObj) : false;
qCDebug(lcQpaMime) << "canGetDibV5:" << canGetDibV5 << "hasOrigDibV5:" << hasOrigDibV5;
if (hasOrigDibV5) {
qCDebug(lcQpaMime) << "Decoding DIBV5";
QImage img;
QByteArray data = getData(CF_DIBV5, pDataObj);
QBuffer buffer(&data);
if (readDib(buffer, img))
return img;
}
// PNG, MS Office place this (undocumented)
if (canGetData(CF_PNG, pDataObj)) {
if (!hasOrigDibV5 && canGetData(CF_PNG, pDataObj)) {
qCDebug(lcQpaMime) << "Decoding PNG";
QImage img;
QByteArray data = getData(CF_PNG, pDataObj);
@ -940,11 +932,11 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject *
return img;
}
}
//Fallback to DIB
if (canGetData(CF_DIB, pDataObj)) {
if (canGetDibV5 || canGetData(CF_DIB, pDataObj)) {
qCDebug(lcQpaMime) << "Decoding DIB";
QImage img;
QByteArray data = getData(CF_DIB, pDataObj);
QByteArray data = getData(canGetDibV5 ? CF_DIBV5 : CF_DIB, pDataObj);
QBuffer buffer(&data);
if (readDib(buffer, img))
return img;