5.15.1: fix for QTBUG-52697

This commit is contained in:
kleuter 2020-10-12 20:49:59 +02:00
parent 26e93867d0
commit e6fd3726f1

View File

@ -87,6 +87,10 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con
QUrl url = QUrl(name); QUrl url = QUrl(name);
qreal sourcePixelRatio = 1.0; qreal sourcePixelRatio = 1.0;
name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio); name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio);
if (name.contains(QLatin1String("@2x")))
url = QUrl(name); // url must be updated! (QTBUG-52697)
const QVariant data = doc->resource(QTextDocument::ImageResource, url); const QVariant data = doc->resource(QTextDocument::ImageResource, url);
if (data.userType() == QMetaType::QPixmap || data.userType() == QMetaType::QImage) { if (data.userType() == QMetaType::QPixmap || data.userType() == QMetaType::QImage) {
pm = qvariant_cast<QPixmap>(data); pm = qvariant_cast<QPixmap>(data);
@ -169,6 +173,10 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format, const
QUrl url = QUrl(name); QUrl url = QUrl(name);
qreal sourcePixelRatio = 1.0; qreal sourcePixelRatio = 1.0;
name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio); name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio);
if (name.contains(QLatin1String("@2x")))
url = QUrl(name); // url must be updated! (QTBUG-52697)
const QVariant data = doc->resource(QTextDocument::ImageResource, url); const QVariant data = doc->resource(QTextDocument::ImageResource, url);
if (data.userType() == QMetaType::QImage) { if (data.userType() == QMetaType::QImage) {
image = qvariant_cast<QImage>(data); image = qvariant_cast<QImage>(data);