Bug 536768: NullPointerException in ColorDialog.open()
Added null checks for handle
Change-Id: I4793514e3e929bf702fd9b10b45d59493377f72a
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 4f118aa..c706ed9 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 @@
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 @@
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 a1db678..bce284b 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 @@
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;
}