diff --git a/Source/AlphaTab/Rendering/Glyphs/TieGlyph.cs b/Source/AlphaTab/Rendering/Glyphs/TieGlyph.cs index 8028eeb53..8161b9741 100644 --- a/Source/AlphaTab/Rendering/Glyphs/TieGlyph.cs +++ b/Source/AlphaTab/Rendering/Glyphs/TieGlyph.cs @@ -48,10 +48,12 @@ public override void Paint(float cx, float cy, ICanvas canvas) var shouldDraw = false; - var direction = GetBeamDirection(StartBeat, startNoteRenderer); - // if we are on the tie start, we check if we + // if we are on the tie start, we check if we // either can draw till the end note, or we just can draw till the bar end - if (!ForEnd) + var direction = startNoteRenderer == null + ? GetBeamDirection(EndBeat, endNoteRenderer) + : GetBeamDirection(StartBeat, startNoteRenderer); + if (!ForEnd && startNoteRenderer != null) { // line break or bar break if (startNoteRenderer != endNoteRenderer) @@ -65,7 +67,7 @@ public override void Paint(float cx, float cy, ICanvas canvas) endX = cx + startNoteRenderer.X + startNoteRenderer.Width; endY = startY; } - // bar break: to tie destination + // bar break: to tie destination // differs only by addition of EndNote X coordinate else { @@ -85,7 +87,7 @@ public override void Paint(float cx, float cy, ICanvas canvas) } // if we draw for the tie end, we only draw a tie if we had a line break between start and end // in this case there will be a tie from bar start to the note - else if (startNoteRenderer.Staff != endNoteRenderer.Staff) + else if (startNoteRenderer == null || startNoteRenderer.Staff != endNoteRenderer.Staff) { startX = cx + endNoteRenderer.X; endX = cx + endNoteRenderer.X + GetEndX(endNoteRenderer); @@ -96,6 +98,7 @@ public override void Paint(float cx, float cy, ICanvas canvas) shouldDraw = true; } + if (shouldDraw) { PaintTie(canvas, @@ -169,7 +172,7 @@ public static void PaintTie( y2 = t; } // - // calculate control points + // calculate control points // offset *= scale;