Bug 578818 - NPE in TextLayout.computeRuns()
Add disposed check for colors to prevent NPE.
Change-Id: I7b9f66ee4ea6da1fa7df31f3d49b9b54bad7bda8
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/191069
Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
Reviewed-by: Lakshmi P Shanmugam <lshanmug@in.ibm.com>
Tested-by: Lakshmi P Shanmugam <lshanmug@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
index 2d00443..23c3df5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
@@ -248,7 +248,7 @@
if (style.strikeout) {
attrStr.addAttribute(OS.NSStrikethroughStyleAttributeName, NSNumber.numberWithInt(OS.NSUnderlineStyleSingle), range);
Color strikeColor = style.strikeoutColor;
- if (strikeColor != null) {
+ if (strikeColor != null && !strikeColor.isDisposed()) {
NSColor color = NSColor.colorWithDeviceRed(strikeColor.handle[0], strikeColor.handle[1], strikeColor.handle[2], 1);
attrStr.addAttribute(OS.NSStrikethroughColorAttributeName, color, range);
}
@@ -277,7 +277,7 @@
if (underlineStyle != 0) {
attrStr.addAttribute(OS.NSUnderlineStyleAttributeName, NSNumber.numberWithInt(underlineStyle), range);
Color underlineColor = style.underlineColor;
- if (underlineColor != null) {
+ if (underlineColor != null && !underlineColor.isDisposed()) {
NSColor color = NSColor.colorWithDeviceRed(underlineColor.handle[0], underlineColor.handle[1], underlineColor.handle[2], 1);
attrStr.addAttribute(OS.NSUnderlineColorAttributeName, color, range);
}