diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2021-04-20 08:41:53 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-21 11:15:07 +0000 |
commit | 8974933d956c798e072f8885fd64a05d8f09c4ab (patch) | |
tree | 702ce349449366f7bf0f048896ddf392814e153a | |
parent | 905e3b66b30df4bf06eb8079cbac2732d452238c (diff) | |
download | qtsvg-8974933d956c798e072f8885fd64a05d8f09c4ab.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.
Change-Id: Ie273bd874d18aeba30fd6b37d91aa72bd3725cd0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 0003ec68e9925a8386eb055e0030fe7f270aa56f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/imageformats/svg/qsvgiohandler.cpp | 11 |
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); |