Skip to content

Commit

Permalink
Fix null reference exception thrown when TextBlock text is null. (str…
Browse files Browse the repository at this point in the history
…ide3d#84)

* Prevent TextBlock from throwing null reference exception when WrapText is set to true and the value of text is null. Fixes issue#82
  • Loading branch information
jayrulez authored and xen2 committed Aug 9, 2018
1 parent 32b2a81 commit b6d3e7d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sources/engine/Xenko.UI/Controls/TextBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ private Vector2 CalculateTextSize(SpriteFont.StringProxy textToMeasure)

private void UpdateWrappedText(Vector3 availableSpace)
{
if (string.IsNullOrEmpty(text))
{
wrappedText = string.Empty;

return;
}

var availableWidth = availableSpace.X;
var currentLine = new StringBuilder(text.Length);
var currentText = new StringBuilder(2 * text.Length);
Expand Down

0 comments on commit b6d3e7d

Please sign in to comment.