Skip to content

Commit

Permalink
Added check for recursive bounds calculation
Browse files Browse the repository at this point in the history
- fixes svg-net#436
  • Loading branch information
mrbean-bremen committed May 8, 2019
1 parent 43f5acc commit 709a32f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Source/Basic Shapes/SvgImage.cs
Expand Up @@ -23,6 +23,7 @@ public SvgImage()
}

private GraphicsPath _path;
private bool _gettingBounds;

/// <summary>
/// Gets an <see cref="SvgPoint"/> representing the top left point of the rectangle.
Expand Down Expand Up @@ -89,9 +90,19 @@ public override RectangleF Bounds
{
get
{
return TransformedBounds(new RectangleF(this.Location.ToDeviceValue(null, this),
if (_gettingBounds)
{
// we can get here recursively in case of percent size units while calculating
// the size of the parent object - in this case just return empty bounds to avoid
// a recursion (see issue #436)
return new RectangleF();
}
_gettingBounds = true;
var bounds = TransformedBounds(new RectangleF(this.Location.ToDeviceValue(null, this),
new SizeF(this.Width.ToDeviceValue(null, UnitRenderingType.Horizontal, this),
this.Height.ToDeviceValue(null, UnitRenderingType.Vertical, this))));
_gettingBounds = false;
return bounds;
}
}

Expand Down

0 comments on commit 709a32f

Please sign in to comment.