Shortcut QImage::convertTo when no conversion is necessary

Avoids a detach when converting to existing format.

Pick-to: 6.0
Change-Id: I9a4801878ddec295a02f2c88f4a40ec13d513a94
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
Allan Sandfeld Jensen 2020-12-07 14:30:25 +01:00
parent fd20bc2277
commit cc81aae4b3
1 changed files with 2 additions and 2 deletions

View File

@ -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();