From 472133d3498d0b1e0e7c4245567c7a1827c2d754 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 20 Aug 2016 13:47:13 +0200 Subject: [PATCH] Catch D2D error and log it. As to not mask e.g. underlying path parse error. --- .../Media/StreamGeometryContextImpl.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs index 5b8e8724d8..4228745d6b 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs @@ -6,6 +6,8 @@ using Avalonia.Platform; using SharpDX.Direct2D1; using SweepDirection = SharpDX.Direct2D1.SweepDirection; using D2D = SharpDX.Direct2D1; +using Avalonia.Logging; +using System; namespace Avalonia.Direct2D1.Media { @@ -76,7 +78,20 @@ namespace Avalonia.Direct2D1.Media public void Dispose() { - _sink.Close(); + // Put a catch around sink.Close as it may throw if there were an error e.g. parsing a path. + try + { + _sink.Close(); + } + catch (Exception ex) + { + Logger.Error( + LogArea.Visual, + this, + "GeometrySink.Close exception: {Exception}", + ex); + } + _sink.Dispose(); } }