Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes empty path issue #1131

Merged
merged 2 commits into from
Jan 19, 2024
Merged

Fixes empty path issue #1131

merged 2 commits into from
Jan 19, 2024

Conversation

paulushub
Copy link
Contributor

@paulushub paulushub commented Jan 19, 2024

Description

The __tiger.svg is marked as passing the tests, but the above commit for 3.4.5 breaks it, by not checking for empty path.
Exception:

Result: TEST FAILED
SVG RENDERING ERROR for __tiger.svg
System.ArgumentException: Parameter is not valid.
   at System.Drawing.Drawing2D.GraphicsPath.get_PathTypes()

Original Code (3.4.4 - https://github.com/svg-net/SVG/blob/v3.4.4/Source/Paths/SvgClosePathSegment.Drawing.cs)

        public override PointF AddToPath(GraphicsPath graphicsPath, PointF start, SvgPathSegmentList parent)
        {
            graphicsPath.CloseFigure();

            var end = start;
            for (var i = graphicsPath.PointCount - 1; i >= 0; --i)
                if ((graphicsPath.PathTypes[i] & 0x7) == 0)
                {
                    end = graphicsPath.PathPoints[i];
                    break;
                }
            return end;
        }

Changed Code (3.4.5 - https://github.com/svg-net/SVG/blob/v3.4.5/Source/Paths/SvgClosePathSegment.Drawing.cs)

        public override PointF AddToPath(GraphicsPath graphicsPath, PointF start, SvgPathSegmentList parent)
        {
            graphicsPath.CloseFigure();

            var end = start;
            var pathTypes = graphicsPath.PathTypes; // ERROR: System.ArgumentException: Parameter is not valid.
            for (var i = graphicsPath.PointCount - 1; i >= 0; --i)
                if ((pathTypes[i] & 0x7) == 0)
                {
                    end = graphicsPath.PathPoints[i];
                    break;
                }
            return end;
        }

Type of change

  • Bug fixes (non-breaking change which fixes an issue)
  • This change does not require a documentation update
  • Resolved review issues (no issue raised).

How Has This Been Tested?

  • SvgW3CTestRunner is tested for each supported platform
  • Svg.UnitTests tested on command line for each supported platform
  • Svg.Benchmarks tested on command line for each supported platform, warnings are as before will be addressed later.

- Fixes issue #1095
- Broken with: Minor optimisations (#1084) commit
@paulushub paulushub merged commit 41ed0b4 into svg-net:master Jan 19, 2024
7 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 19, 2024
…amples Source Svg.Custom Tests doc docfx.json index.md license.txt Fixes empty path issue - Fixes issue #1095
 - Broken with: Minor optimisations (#1084) commit
 
 CONTRIBUTING.md Generators README.md Samples Source Svg.Custom Tests doc docfx.json index.md license.txt Update ReleaseNotes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Parameter is not valid" exception when document misses width and/or height
2 participants