diff options
| author | Lakshmi Shanmugam | 2015-12-01 12:08:30 +0000 |
|---|---|---|
| committer | Lakshmi Shanmugam | 2016-01-11 10:16:08 +0000 |
| commit | 3e30fac11a11e522e98cb140095cc4e29c2d4371 (patch) | |
| tree | fb178d84c3f44819a63e5b4e191af3076a684c12 | |
| parent | 50447d20506d87bd24092b59e3e9a7ad6ef9764a (diff) | |
| download | eclipse.platform.swt-3e30fac11a11e522e98cb140095cc4e29c2d4371.tar.gz eclipse.platform.swt-3e30fac11a11e522e98cb140095cc4e29c2d4371.tar.xz eclipse.platform.swt-3e30fac11a11e522e98cb140095cc4e29c2d4371.zip | |
Bug 434393 - [10.11] OS X: NPE in Control.internal_new_GC
NSGraphicsContext currentContext() returns null on OSX 10.11 when called
from a
non-drawing method, for eg, Table.cellSize(). The fix to is to check if
the context returned is valid, if not we create a new context using
NSGraphicsContext.graphicsContextWithWindow.
| -rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java index 366da3de13..cb838c242b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java @@ -2118,12 +2118,12 @@ boolean insertText (long /*int*/ id, long /*int*/ sel, long /*int*/ string) { public long /*int*/ internal_new_GC (GCData data) { checkWidget(); NSView view = paintView(); - long /*int*/ context = 0; + NSGraphicsContext graphicsContext = null; if (data != null && data.paintRect != null) { - NSGraphicsContext graphicsContext = NSGraphicsContext.currentContext(); - context = graphicsContext.id; + graphicsContext = NSGraphicsContext.currentContext(); if (!view.isFlipped()) data.state &= ~VISIBLE_REGION; - } else { + } + if (graphicsContext == null) { NSWindow window = view.window(); /* * Force the device to be created before attempting @@ -2136,10 +2136,9 @@ public long /*int*/ internal_new_GC (GCData data) { window.orderOut(null); window.setAlphaValue(alpha); } - NSGraphicsContext graphicsContext = NSGraphicsContext.graphicsContextWithWindow (window); + graphicsContext = NSGraphicsContext.graphicsContextWithWindow (window); NSGraphicsContext flippedContext = NSGraphicsContext.graphicsContextWithGraphicsPort(graphicsContext.graphicsPort(), true); graphicsContext = flippedContext; - context = graphicsContext.id; if (data != null) { data.flippedContext = flippedContext; data.state &= ~VISIBLE_REGION; @@ -2163,7 +2162,10 @@ public long /*int*/ internal_new_GC (GCData data) { data.background = control.getBackgroundColor ().handle; data.font = font != null ? font : defaultFont (); } - return context; + if (graphicsContext != null) { + return graphicsContext.id; + } + return 0; } /** |
