summaryrefslogtreecommitdiffstats
path: root/src/plugins/imageformats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2020-06-05 16:09:43 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2020-06-26 15:24:05 +0200
commit1a63409579ff0e9ce524c09701c1ef8bd2d99f25 (patch)
treed6a77e05c987fc6f6aef9f68e5a1a2f1e6731260 /src/plugins/imageformats
parent5dea4fe956c452be5aae2c61dd0777fdf1efe5d0 (diff)
QImageIO: use the new allocation checker in the format handlers
Change-Id: I604d99ce476d4758a1e20b78257082911f1f1546 Task-number: QTBUG-85037 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/imageformats')
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp12
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp5
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp5
3 files changed, 11 insertions, 11 deletions
diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index 078d3d596d..e895e4f91b 100644
--- a/src/plugins/imageformats/gif/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
@@ -358,7 +358,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
state = Error;
return -1;
}
- (*image) = QImage(swidth, sheight, format);
+ if (!QImageIOHandler::allocateImage(QSize(swidth, sheight), format, image)) {
+ state = Error;
+ return -1;
+ }
bpl = image->bytesPerLine();
bits = image->bits();
if (bits)
@@ -425,10 +428,9 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
return -1;
}
// We just use the backing store as a byte array
- backingstore = QImage(qMax(backingstore.width(), w),
- qMax(backingstore.height(), h),
- QImage::Format_RGB32);
- if (backingstore.isNull()) {
+ QSize bsSize(qMax(backingstore.width(), w), qMax(backingstore.height(), h));
+ if (!QImageIOHandler::allocateImage(bsSize, QImage::Format_RGB32,
+ &backingstore)) {
state = Error;
return -1;
}
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp
index d7b2fc64c2..631d7e8d0f 100644
--- a/src/plugins/imageformats/ico/qicohandler.cpp
+++ b/src/plugins/imageformats/ico/qicohandler.cpp
@@ -521,8 +521,9 @@ QImage ICOReader::iconAt(int index)
else if (icoAttrib.ncolors > 0)
format = QImage::Format_Indexed8;
- QImage image(icoAttrib.w, icoAttrib.h, format);
- if (!image.isNull()) {
+ QImage image;
+ const QSize size(icoAttrib.w, icoAttrib.h);
+ if (QImageIOHandler::allocateImage(size, format, &image)) {
findColorInfo(image);
if (!image.isNull()) {
readBMP(image);
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index 25b0c625fd..1b48e8fc90 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -240,10 +240,7 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
return false; // unsupported format
}
- if (dest->size() != size || dest->format() != format)
- *dest = QImage(size, format);
-
- return !dest->isNull();
+ return QImageIOHandler::allocateImage(size, format, dest);
}
static bool read_jpeg_image(QImage *outImage,