summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2021-04-20 08:41:53 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2021-06-08 08:22:37 +0000
commit0003ec68e9925a8386eb055e0030fe7f270aa56f (patch)
treec9103e7937436e2398430ff76cd8099db3d53619 /src
parent749a1ee6611dfd1200d476e3bf8c63159fb5fdbb (diff)
downloadqtsvg-0003ec68e9925a8386eb055e0030fe7f270aa56f.tar.gz
Use checked image allocation in image reader
Utilize imageIO's common QImage creation function that implements QImageReader's allocation limit that was introduced in Qt 6. Pick-to: 6.1 Change-Id: Ie273bd874d18aeba30fd6b37d91aa72bd3725cd0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp
index 4136aaf..3e338b3 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.cpp
+++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp
@@ -181,14 +181,11 @@ bool QSvgIOHandler::read(QImage *image)
t.translate(tr1.x(), tr1.y());
bounds = t.mapRect(bounds);
}
- if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied)) {
- *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied);
- if (!finalSize.isEmpty() && image->isNull()) {
- qWarning("QSvgIOHandler: QImage allocation failed (size %i x %i)", finalSize.width(), finalSize.height());
+ if (finalSize.isEmpty()) {
+ *image = QImage();
+ } else {
+ if (!QImageIOHandler::allocateImage(finalSize, QImage::Format_ARGB32_Premultiplied, image))
return false;
- }
- }
- if (!finalSize.isEmpty()) {
image->fill(d->backColor.rgba());
QPainter p(image);
d->r.render(&p, bounds);