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: