diff options
| author | Lakshmi Shanmugam | 2015-12-01 12:08:30 +0000 |
|---|---|---|
| committer | Lakshmi Shanmugam | 2015-12-01 12:15:01 +0000 |
| commit | 7bbf8d4559e0a792751c656ac72cdd3326f6a324 (patch) | |
| tree | 0af0077a0d2828a21fb71a7b7d483173fbbbcaeb | |
| parent | a69323ae0efd13eb2abd478b966db61020e85628 (diff) | |
| download | eclipse.platform.swt-7bbf8d4559e0a792751c656ac72cdd3326f6a324.tar.gz eclipse.platform.swt-7bbf8d4559e0a792751c656ac72cdd3326f6a324.tar.xz eclipse.platform.swt-7bbf8d4559e0a792751c656ac72cdd3326f6a324.zip | |
Bug 434393 - [10.11] OS X: NPE in Control.internal_new_GC
NSGraphicsContext currentContext() returns null on )SX 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 7cf0cf2b32..0870bb9aa4 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 @@ -2152,12 +2152,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 @@ -2170,10 +2170,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; @@ -2197,7 +2196,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; } /** |
