From e64b2234e829cc47872225debcf80d6c06db18f0 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 10 May 2016 14:47:31 +0200 Subject: QImage::setPixelColor: warn about invalid colors Task-number: QTBUG-52142 Change-Id: I9f390bd332f8edabaece75a6b36830c691ff4b9e Reviewed-by: Gunnar Sletta --- src/gui/image/qimage.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 64a53b4c0e..2911477d28 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2455,10 +2455,16 @@ QColor QImage::pixelColor(int x, int y) const */ void QImage::setPixelColor(int x, int y, const QColor &color) { - if (!d || x < 0 || x >= width() || y < 0 || y >= height() || !color.isValid()) { + if (!d || x < 0 || x >= width() || y < 0 || y >= height()) { qWarning("QImage::setPixelColor: coordinate (%d,%d) out of range", x, y); return; } + + if (!color.isValid()) { + qWarning("QImage::setPixelColor: color is invalid"); + return; + } + // QColor is always unpremultiplied QRgba64 c = color.rgba64(); if (!hasAlphaChannel()) -- cgit v1.2.3