Fix a crash with null textfields.

This commit is contained in:
Paul Chote
2011-03-13 02:29:44 +13:00
parent a33cca57ec
commit c7d25bb991

View File

@@ -64,6 +64,9 @@ namespace OpenRA.Widgets
public int ClosestCursorPosition(int x) public int ClosestCursorPosition(int x)
{ {
if (Text == null)
return 0;
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont; var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
var textSize = font.Measure(Text); var textSize = font.Measure(Text);
@@ -141,6 +144,9 @@ namespace OpenRA.Widgets
} }
else if (!char.IsControl(c)) else if (!char.IsControl(c))
{ {
if (Text == null)
Text = "";
if (MaxLength > 0 && Text.Length >= MaxLength) if (MaxLength > 0 && Text.Length >= MaxLength)
return; return;