Check if CurrentSubpath is null in CloseSubpath()

This commit is contained in:
BobLd
2020-04-04 13:37:25 +01:00
committed by Eliot Jones
parent 16a17f3b8d
commit ec2dcdc9f4
4 changed files with 13 additions and 4 deletions

View File

@@ -66,7 +66,7 @@
{
}
public PdfPoint CloseSubpath()
public PdfPoint? CloseSubpath()
{
return new PdfPoint();
}

View File

@@ -419,8 +419,13 @@
CurrentSubpath = new PdfSubpath();
}
public PdfPoint CloseSubpath()
public PdfPoint? CloseSubpath()
{
if (CurrentSubpath == null)
{
return null;
}
PdfPoint point;
if (CurrentSubpath.Commands[0] is Move move)
{

View File

@@ -89,7 +89,7 @@
/// <summary>
/// Close the current subpath.
/// </summary>
PdfPoint CloseSubpath();
PdfPoint? CloseSubpath();
/// <summary>
/// Add the current subpath to the path.

View File

@@ -29,7 +29,11 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.CurrentPosition = operationContext.CloseSubpath();
var point = operationContext.CloseSubpath();
if (point.HasValue)
{
operationContext.CurrentPosition = point.Value;
}
}
/// <inheritdoc />