diff options
author | Lakshmi Shanmugam | 2018-07-19 12:21:07 +0000 |
---|---|---|
committer | Lakshmi Shanmugam | 2018-07-23 08:57:58 +0000 |
commit | be13abb1970d76b1275ba113f678ec95097bf0c5 (patch) | |
tree | 218e9fb57fe62c2d9662b5970306bf04870a23f7 | |
parent | 0aa92e62e6bfa1b054314f9a94b90c49428a789e (diff) | |
download | eclipse.platform.swt-be13abb1970d76b1275ba113f678ec95097bf0c5.tar.gz eclipse.platform.swt-be13abb1970d76b1275ba113f678ec95097bf0c5.tar.xz eclipse.platform.swt-be13abb1970d76b1275ba113f678ec95097bf0c5.zip |
Bug 536768: NullPointerException in ColorDialog.open()Y20180723-0615
Added null checks for handle
Change-Id: I4793514e3e929bf702fd9b10b45d59493377f72a
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java | 8 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FontDialog.java | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java index 4f118aa01f..c706ed900e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ColorDialog.java @@ -184,7 +184,9 @@ public RGB open() { NSColor color = panel.color(); if (color != null) { double /*float*/ [] handle = display.getNSColorRGB(color); - rgb = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + if (handle != null) { + rgb = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + } } } NSArray keys = colorList.allKeys(); @@ -193,7 +195,9 @@ public RGB open() { for (int i=0; i<length; i++) { NSString key = new NSString(keys.objectAtIndex(i)); double /*float*/ [] handle = display.getNSColorRGB(colorList.colorWithKey(key)); - rgbs[i] = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + if (handle != null) { + rgbs[i] = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + } } colorList.release(); return rgb; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FontDialog.java index a1db67892a..bce284b7c2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FontDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FontDialog.java @@ -195,7 +195,9 @@ void setColor_forAttribute(long /*int*/ id, long /*int*/ sel, long /*int*/ color NSColor color = new NSColor(colorArg); Display display = parent != null ? parent.getDisplay() : Display.getCurrent(); double /*float*/ [] handle = display.getNSColorRGB(color); - rgb = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + if (handle != null) { + rgb = new RGB((int)(handle[0] * 255), (int)(handle[1] * 255), (int)(handle[2] * 255)); + } } else { rgb = null; } |