From c4d8be28dbf96687a9651eb287637ff535bdebb6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Jun 2017 15:15:50 +0200 Subject: Do not reallocate memory for QImage If the QImage given to read() already has the right size and depth, we don't need to allocate a new image. This is consistent with other image decoders and why a QImage is provided to the method in the first place. Change-Id: I4944211d4a8d4f19d000cace4a48df505d375f52 Reviewed-by: Eirik Aavitsland --- src/plugins/imageformats/svg/qsvgiohandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp index 0c26cb5..457c79e 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.cpp +++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp @@ -176,7 +176,8 @@ bool QSvgIOHandler::read(QImage *image) t.translate(tr1.x(), tr1.y()); bounds = t.mapRect(bounds); } - *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied); + if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied)) + *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied); if (!finalSize.isEmpty()) { image->fill(d->backColor.rgba()); QPainter p(image); -- cgit v1.2.1