Skip to content

Commit b4b8559

Browse files
committed
StringItem: Make sure we won't process or render null objects.
Should fix Akalabeth. Related to #168
1 parent 79a4030 commit b4b8559

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/javax/microedition/lcdui/StringItem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ protected int getContentHeight(int width)
7474
{
7575
height = Font.getDefaultFont().getHeight() + 2*buttonMargin + 2*buttonPadding;
7676
}
77-
else if (height == 0 && !text.isEmpty())
77+
else if (height == 0 && text != null && !text.isEmpty())
7878
{
7979
lines = wrapText(text, width, Font.getDefaultFont());
8080
lineSpacing = 1;
8181

8282
height = lines.size() > 0 ? (lines.size()*Font.getDefaultFont().getHeight() + (lines.size()-1)*lineSpacing) : 0;
8383
}
84-
else if (text.isEmpty() && lines == null) { lines = new ArrayList<String>(); }
84+
else if ((text == null || text.isEmpty()) && lines == null) { lines = new ArrayList<String>(); }
8585

8686
return height;
8787
}
@@ -117,7 +117,7 @@ public static List<String> wrapText(String text, int width, Font font)
117117

118118
protected void renderItem(Graphics graphics, int x, int y, int width, int height)
119119
{
120-
if (appearance == Item.BUTTON)
120+
if (appearance == Item.BUTTON)
121121
{
122122
graphics.setColor(Mobile.lcduiBGColor);
123123
graphics.fillRect(x+buttonMargin, y+buttonMargin, width-2*buttonMargin, height-2*buttonMargin);
@@ -128,7 +128,7 @@ protected void renderItem(Graphics graphics, int x, int y, int width, int height
128128
graphics.setColor(Mobile.lcduiTextColor);
129129
graphics.drawString(text, x+buttonMargin+buttonPadding, y+buttonMargin+buttonPadding, 0);
130130
}
131-
else
131+
else
132132
{
133133
graphics.setColor(Mobile.lcduiTextColor);
134134
for(int l=0;l<lines.size();l++)

0 commit comments

Comments
 (0)