path: root/src/plugins/platforms/cocoa
diff options
authorGabriel de Dietrich <>2013-07-02 15:21:07 +0200
committerThe Qt Project <>2013-07-02 16:33:08 +0200
commit323164f5fbfbd56c1a0c2d856e440a87b0ed73c7 (patch)
tree18979a8cce6e0edc6b56347007e48b186166556e /src/plugins/platforms/cocoa
parentfa1fb5ed945650d45cf9b61906232cfbae11360e (diff)
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 <>
Diffstat (limited to 'src/plugins/platforms/cocoa')
1 files changed, 2 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/ b/src/plugins/platforms/cocoa/
index 9c10bc26dd..13a387a0a3 100644
--- a/src/plugins/platforms/cocoa/
+++ b/src/plugins/platforms/cocoa/
@@ -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)
QPixmap pixmap = QPixmap::fromImage(qt_mac_toQImage(cgImage));
return pixmap;