forked from qt-creator/qt-creator
WelcomeScreen: Don't rely on image format auto-detection
The examples and marketplace pages show images that are decoded from data buffers. This happened without specifying the encoding format, which triggers image auto-detection. The negligible overhead of the auto-detection is usually not a problem, but the probing of image QImageIOHandlers that goes along with auto- detection can emit warnings. A concrete example is a warning in the TGA plugin which was added in Qt 5.15.1. Task-number: QTCREATORBUG-24853 Change-Id: I596604bde7621acf92e825f45e0c23ac4e90b78d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@@ -380,7 +381,8 @@ void SectionedProducts::onImageDownloadFinished(QNetworkReply *reply)
|
|||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
const QByteArray data = reply->readAll();
|
const QByteArray data = reply->readAll();
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
if (pixmap.loadFromData(data)) {
|
const QString imageFormat = QFileInfo(reply->request().url().fileName()).suffix();
|
||||||
|
if (pixmap.loadFromData(data, imageFormat.toLatin1())) {
|
||||||
const QString url = reply->request().url().toString();
|
const QString url = reply->request().url().toString();
|
||||||
QPixmapCache::insert(url, pixmap.scaled(ProductListModel::defaultImageSize,
|
QPixmapCache::insert(url, pixmap.scaled(ProductListModel::defaultImageSize,
|
||||||
Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ QPixmap ExamplesListModel::fetchPixmapAndUpdatePixmapCache(const QString &url) c
|
|||||||
if (!fetchedData.isEmpty()) {
|
if (!fetchedData.isEmpty()) {
|
||||||
QBuffer imgBuffer(&fetchedData);
|
QBuffer imgBuffer(&fetchedData);
|
||||||
imgBuffer.open(QIODevice::ReadOnly);
|
imgBuffer.open(QIODevice::ReadOnly);
|
||||||
QImageReader reader(&imgBuffer);
|
QImageReader reader(&imgBuffer, QFileInfo(url).suffix().toLatin1());
|
||||||
QImage img = reader.read();
|
QImage img = reader.read();
|
||||||
img = ScreenshotCropper::croppedImage(img, url, ListModel::defaultImageSize);
|
img = ScreenshotCropper::croppedImage(img, url, ListModel::defaultImageSize);
|
||||||
pixmap = QPixmap::fromImage(img);
|
pixmap = QPixmap::fromImage(img);
|
||||||
|
|||||||
Reference in New Issue
Block a user