From f30fb442af3e330057e1939bf3e42c317f65a788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 6 Sep 2024 13:20:01 +0200 Subject: [PATCH] macOS: Return invalid QColor if qt_mac_toQColor is called with a nil NSColor Call sites of qt_mac_toQColor may not necessarily check the NSColor for nil before passing it to qt_mac_toQColor, as seen for example in the QCocoaColorPicker implementation. Without an explicit nil check we ended up returning a valid QColor with all color components set to 0. Pick-to: 6.7 Change-Id: I0cc36049fca05a6b668c0c610bc40eedbc72df3a Reviewed-by: Doris Verria (cherry picked from commit 271bfe4a5405309dc8d48807d6f28d174efb2cc2) Reviewed-by: Qt Cherry-pick Bot --- src/gui/painting/qcoregraphics.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index 27b46202f50..40fe5bdd144 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -228,6 +228,9 @@ QColor qt_mac_toQColor(CGColorRef color) #ifdef Q_OS_MACOS QColor qt_mac_toQColor(const NSColor *color) { + if (!color) + return QColor(); + QColor qtColor; switch (color.type) { case NSColorTypeComponentBased: {