Browse Source

Fix problems with mutable brush being passed to an immutable pen.

pull/6039/head
Dariusz Komosinski 5 years ago
parent
commit
6f5bf52178
  1. 15
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  2. 3
      src/Avalonia.Visuals/Media/Immutable/ImmutablePen.cs

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

@ -361,9 +361,9 @@ namespace Avalonia.Controls.Presenters
RenderInternal(context); RenderInternal(context);
if (selectionStart == selectionEnd) if (selectionStart == selectionEnd && _caretBlink)
{ {
var caretBrush = CaretBrush; var caretBrush = CaretBrush?.ToImmutable();
if (caretBrush is null) if (caretBrush is null)
{ {
@ -382,13 +382,10 @@ namespace Avalonia.Controls.Presenters
} }
} }
if (_caretBlink) var (p1, p2) = GetCaretPoints();
{ context.DrawLine(
var (p1, p2) = GetCaretPoints(); new ImmutablePen(caretBrush, 1),
context.DrawLine( p1, p2);
new ImmutablePen(caretBrush, 1),
p1, p2);
}
} }
} }

3
src/Avalonia.Visuals/Media/Immutable/ImmutablePen.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
namespace Avalonia.Media.Immutable namespace Avalonia.Media.Immutable
{ {
@ -44,6 +45,8 @@ namespace Avalonia.Media.Immutable
PenLineJoin lineJoin = PenLineJoin.Miter, PenLineJoin lineJoin = PenLineJoin.Miter,
double miterLimit = 10.0) double miterLimit = 10.0)
{ {
Debug.Assert(!(brush is IMutableBrush));
Brush = brush; Brush = brush;
Thickness = thickness; Thickness = thickness;
LineCap = lineCap; LineCap = lineCap;

Loading…
Cancel
Save