From f60f62f091e65f3d4cbb0a4c1d7e98bc0cab7be5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 7 Dec 2020 14:30:25 +0100 Subject: [PATCH] Shortcut QImage::convertTo when no conversion is necessary Avoids a detach when converting to existing format. Change-Id: I9a4801878ddec295a02f2c88f4a40ec13d513a94 Reviewed-by: Eirik Aavitsland (cherry picked from commit cc81aae4b312da40945ddfecb806f4abe6b74048) Reviewed-by: Qt Cherry-pick Bot --- src/gui/image/qimage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 70b958c177e..7ca5b133738 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2239,7 +2239,7 @@ bool QImage::reinterpretAsFormat(Format format) /*! \since 5.13 - Detach and convert the image to the given \a format in place. + Converts the image to the given \a format in place, detaching if necessary. The specified image conversion \a flags control how the image data is handled during the conversion process. @@ -2249,7 +2249,7 @@ bool QImage::reinterpretAsFormat(Format format) void QImage::convertTo(Format format, Qt::ImageConversionFlags flags) { - if (!d || format == QImage::Format_Invalid) + if (!d || format == QImage::Format_Invalid || d->format == format) return; detach();