Skip to content

Commit ee1713a

Browse files
committed
Fix possible NPE in StyledText
The content might go null in certain cases so adding a null check as safeguard Fixes: #658
1 parent d399c4c commit ee1713a

File tree

1 file changed

+8
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom

1 file changed

+8
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8290,8 +8290,10 @@ public void setBackground(Color color) {
82908290
customBackground = color != null && !this.insideSetEnableCall && !backgroundDisabled;
82918291
background = color;
82928292
super.setBackground(color);
8293-
resetCache(0, content.getLineCount());
8294-
setCaretLocations();
8293+
if (content != null) {
8294+
resetCache(0, content.getLineCount());
8295+
setCaretLocations();
8296+
}
82958297
super.redraw();
82968298
}
82978299
/**
@@ -8885,8 +8887,10 @@ public void setForeground(Color color) {
88858887
customForeground = color != null && !this.insideSetEnableCall && !foregroundDisabled;
88868888
foreground = color;
88878889
super.setForeground(color);
8888-
resetCache(0, content.getLineCount());
8889-
setCaretLocations();
8890+
if (content != null) {
8891+
resetCache(0, content.getLineCount());
8892+
setCaretLocations();
8893+
}
88908894
super.redraw();
88918895
}
88928896
/**

0 commit comments

Comments
 (0)