From ce0af99f47c1728a6d8145ea89f41b1c9207104a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 6 Apr 2010 16:08:20 +0200 Subject: Prevented unnecessary copy in QImage::setAlphaChannel(). If the formats don't match the detch is unnecessary as operator= will anyways destroy the detached QImageData and substitute it with the newly created QImageData from convertToFormat. Task-number: QTBUG-9640 Reviewed-by: Trond --- src/gui/image/qimage.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 233c58d..ce1d6d3 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5704,9 +5704,10 @@ void QImage::setAlphaChannel(const QImage &alphaChannel) return; } - detach(); - - *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); + if (d->format == QImage::Format_ARGB32_Premultiplied) + detach(); + else + *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); // Slight optimization since alphachannels are returned as 8-bit grays. if (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale()) { -- cgit v0.12