From: Jean-Philippe Bruyère Date: Thu, 18 Mar 2021 12:50:38 +0000 (+0100) Subject: prevent SvgPicture to cause exception if picture not loaded X-Git-Tag: v0.9.5-beta~57 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=9023932880b5af2575eb54b4379c753152780427;p=jp%2Fcrow.git prevent SvgPicture to cause exception if picture not loaded --- diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index f09f66dc..9cff5e2d 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -23,7 +23,7 @@ True true $(NoWarn);1591;1587;1570;1572;1573;1574 - _DESIGN_MODE;_MEASURE_TIME + DESIGN_MODE;_MEASURE_TIME;_DEBUG_HIGHLIGHT_FOCUS false false @@ -51,7 +51,7 @@ - + Crow.%(Filename).template diff --git a/Crow/src/Fill/SvgPicture.cs b/Crow/src/Fill/SvgPicture.cs index 4f378be4..fcd5c4d2 100644 --- a/Crow/src/Fill/SvgPicture.cs +++ b/Crow/src/Fill/SvgPicture.cs @@ -27,17 +27,20 @@ namespace Crow public SvgPicture (string path) : base(path) {} #endregion - void load (Interface iFace) - { + bool load (Interface iFace) + { + if (string.IsNullOrEmpty(Path)) + return false; if (iFace.sharedPictures.ContainsKey (Path)) { sharedPicture sp = iFace.sharedPictures [Path]; hSVG = (Rsvg.Handle)sp.Data; Dimensions = sp.Dims; - return; + return true; } using (Stream stream = iFace.GetStreamFromPath (Path)) load (stream); iFace.sharedPictures [Path] = new sharedPicture (hSVG, Dimensions); + return true; } void load (Stream stream) { using (BinaryReader sr = new BinaryReader (stream)) { @@ -61,7 +64,8 @@ namespace Crow public override void SetAsSource (Interface iFace, Context ctx, Rectangle bounds = default(Rectangle)) { if (hSVG == null) - load (iFace); + if (!load (iFace)) + return; float widthRatio = 1f; float heightRatio = 1f; @@ -101,7 +105,8 @@ namespace Crow public override void Paint (Interface iFace, Context gr, Rectangle rect, string subPart = "") { if (hSVG == null) - load (iFace); + if (!load (iFace)) + return; float widthRatio = 1f; float heightRatio = 1f; diff --git a/Directory.Build.props b/Directory.Build.props index 89659e1d..650c49bd 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,5 @@ - $(MSBuildThisFileDirectory) $(SolutionDir)build\$(Configuration)\ $(SolutionDir)build\obj\$(Configuration)\ MIT