Update SVGBezierPath.mm#235
Closed
markm68k wants to merge 1 commit intopocketsvg:masterfrom
markm68k:mark-miller0-patch-1
Closed
Update SVGBezierPath.mm#235markm68k wants to merge 1 commit intopocketsvg:masterfrom markm68k:mark-miller0-patch-1
markm68k wants to merge 1 commit intopocketsvg:masterfrom
markm68k:mark-miller0-patch-1
Conversation
• Ensure that pathBySettingSVGAttributes: always returns a non-null value. • If [self copy] returns nil, return self or create a new instance as a fallback. • Add a comment explaining the fallback.
Author
|
Addresses open issue #229 |
Author
|
I'm not certain this is the right fix. However with the current implementation if copy fails, the method will return nil. Perhaps this is the safest option, as callers can check for nil and handle errors appropriately, avoiding accidental unintended mutations if returning self. If the decision is to allow returning nil, then changing the header file for pathBySettingSVGAttributes: should be defined as such in the header. |
arielelkin
reviewed
Oct 28, 2025
Comment on lines
+95
to
+96
| // Fallback if copy returns nil, ensure non-null return. | ||
| path = self; |
Collaborator
There was a problem hiding this comment.
falling back to self when self copy returns nil breaks the contract of this method, because callers expect a distinct instance. how about:
Suggested change
| // Fallback if copy returns nil, ensure non-null return. | |
| path = self; | |
| // Fallback if copy returns nil, ensure non-null return. | |
| SVGBezierPath *newPath = [SVGBezierPath bezierPathWithCGPath:self.CGPath]; | |
| newPath.lineWidth = self.lineWidth; | |
| newPath.flatness = self.flatness; | |
| newPath.miterLimit = self.miterLimit; | |
| path = newPath; | |
Author
There was a problem hiding this comment.
Agreed. I like this fallback solution much better.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
• Ensure that pathBySettingSVGAttributes: always returns a non-null value. • If [self copy] returns nil, return self or create a new instance as a fallback. • Add a comment explaining the fallback.
Thank you for submitting a PR for PocketSVG 😀
If you're fixing an issue, please briefly describe the current behaviour and the new behaviour. If you're addressing an open issue, please link to it.
If you're introducing a new feature, please briefly describe the new behavior and provide code + sample SVGs for us to see it in action.
Please also add that as an entry in our
CHANGELOG.mdfile to explain your changes and credit yourself. Add the entry in the appropriate section (New Features / Fixes / Internal Change / Breaking Change) underUnreleased. Add links to your GitHub profile and to the related PR and issue after your description. Be part of history.