From 323164f5fbfbd56c1a0c2d856e440a87b0ed73c7 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 2 Jul 2013 15:21:07 +0200 Subject: [PATCH] Avoid warnings when fetching file icons without a CGContextRef This can happen when instantiating a QFileIconProvider and no suitable graphics context is available (e.g., when only using a QQuickView). The proper, longer (5.2) term solution would be to have the platform theme return a QIcon with a NSImage icon provider. Task-number: QTBUG-31908 Change-Id: Ibfdb51e0a7dd2c33761a463f4eb6619f0aca19f0 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoatheme.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 9c10bc26dd..13a387a0a3 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -258,8 +258,9 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz return QPixmap(); NSRect iconRect = NSMakeRect(0, 0, size.width(), size.height()); + NSGraphicsContext *gc = [NSGraphicsContext currentContext]; CGImageRef cgImage = [iconImage CGImageForProposedRect:&iconRect - context:[NSGraphicsContext currentContext] + context:([gc graphicsPort] ? gc : nil) hints:nil]; QPixmap pixmap = QPixmap::fromImage(qt_mac_toQImage(cgImage)); return pixmap;