From e6b1d99ff2842c81a8982053a57e9f9b2f875fa5 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Fri, 26 May 2023 10:27:10 +0200 Subject: [PATCH] QMacCGContext::initialize: Handle QPixmap without platform pixmap Regression after 585150e3d947d0ee30489f275e7fc39bce4fe059. (cherry picked from commit 195c893424a386d66cbec01c777e08c54d6af49a) Change-Id: Ie728904736dd41fb8dfa6ecc9f843beea95b4604 Reviewed-by: Tim Jenssen --- src/gui/painting/qcoregraphics.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index b03ebe55e6c..c05ba06146a 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -386,11 +386,14 @@ void QMacCGContext::initialize(QPaintDevice *paintDevice) // Find the underlying QImage of the paint device switch (int deviceType = paintDevice->devType()) { case QInternal::Pixmap: { - auto *platformPixmap = static_cast(paintDevice)->handle(); - if (platformPixmap && platformPixmap->classId() == QPlatformPixmap::RasterClass) - initialize(platformPixmap->buffer()); - else - qWarning() << "QMacCGContext: Unsupported pixmap class" << platformPixmap->classId(); + if (auto *platformPixmap = static_cast(paintDevice)->handle()) { + if (platformPixmap->classId() == QPlatformPixmap::RasterClass) + initialize(platformPixmap->buffer()); + else + qWarning() << "QMacCGContext: Unsupported pixmap class" << platformPixmap->classId(); + } else { + qWarning() << "QMacCGContext: Empty platformPixmap"; + } break; } case QInternal::Image: