Browse Source

[Text] Dispose Text Layout in TextBlock and TextPresenter

pull/9954/head
Sergey Mikolaitis 4 years ago
parent
commit
f6535c6b26
  1. 3
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  2. 11
      src/Avalonia.Controls/TextBlock.cs

3
src/Avalonia.Controls/Presenters/TextPresenter.cs

@ -588,6 +588,7 @@ namespace Avalonia.Controls.Presenters
protected virtual void InvalidateTextLayout()
{
_textLayout?.Dispose();
_textLayout = null;
InvalidateMeasure();
@ -597,6 +598,7 @@ namespace Avalonia.Controls.Presenters
{
_constraint = availableSize;
_textLayout?.Dispose();
_textLayout = null;
InvalidateArrange();
@ -622,6 +624,7 @@ namespace Avalonia.Controls.Presenters
_constraint = new Size(Math.Ceiling(finalSize.Width), double.PositiveInfinity);
_textLayout?.Dispose();
_textLayout = null;
return finalSize;

11
src/Avalonia.Controls/TextBlock.cs

@ -173,13 +173,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets the <see cref="TextLayout"/> used to render the text.
/// </summary>
public TextLayout TextLayout
{
get
{
return _textLayout ??= CreateTextLayout(_text);
}
}
public TextLayout TextLayout => _textLayout ??= CreateTextLayout(_text);
/// <summary>
/// Gets or sets the padding to place around the <see cref="Text"/>.
@ -648,6 +642,7 @@ namespace Avalonia.Controls
/// </summary>
protected void InvalidateTextLayout()
{
_textLayout?.Dispose();
_textLayout = null;
InvalidateVisual();
@ -663,6 +658,7 @@ namespace Avalonia.Controls
_constraint = availableSize.Deflate(padding);
_textLayout?.Dispose();
_textLayout = null;
var inlines = Inlines;
@ -726,6 +722,7 @@ namespace Avalonia.Controls
_constraint = new Size(Math.Ceiling(finalSize.Deflate(padding).Width), double.PositiveInfinity);
_textLayout?.Dispose();
_textLayout = null;
if (HasComplexContent)

Loading…
Cancel
Save