Skip to content

Fix NSData crash when url or path cannot be opened#554

Open
teffi wants to merge 5 commits into
SVGKit:2.xfrom
teffi:develop
Open

Fix NSData crash when url or path cannot be opened#554
teffi wants to merge 5 commits into
SVGKit:2.xfrom
teffi:develop

Conversation

@teffi

@teffi teffi commented Jan 24, 2018

Copy link
Copy Markdown

Added try-catch-finally to avoid fatal exception when loading image contents of a path or url.

Error internally in Apple's NSData trying to read from URL 'path to svg file'. Error = Error Domain=NSCocoaErrorDomain Code=256 "The file “svg filename” couldn’t be opened." UserInfo={NSURL=path to svg file}

Use:
+[SVGKImage imageWithContentsOfURL:completion:]
+[SVGKImage imageWithContentsOfFile:completion:]

@adamgit

adamgit commented Jan 24, 2018

Copy link
Copy Markdown
Contributor

Why have you created a new completion block for this?

The old block should be sufficient - but if not, please change ALL the instances, don't create a new, duplicate, typedef. Your new block forces peolpe to duplicate their code and handle both outcomes - and it also appears to discard critical information - you've lost ALL the parse data, no?

@teffi

teffi commented Jan 24, 2018

Copy link
Copy Markdown
Author

Sorry. I was trying to create a simpler and more straight forward block when one just needs the SVGKImage and not the SVGKParseResult object. If you feel strongly about reusing the existing typedef, sure.

Yes. I just noticed the wrong completion instance checking. The block is not invoked at all. Sigh

@adamgit

adamgit commented Jan 24, 2018 via email

Copy link
Copy Markdown
Contributor

@teffi

teffi commented Jan 24, 2018

Copy link
Copy Markdown
Author

Noted. Will keep that in mind.

@adamgit

adamgit commented Nov 23, 2018

Copy link
Copy Markdown
Contributor

UPDATE: now we've started a 3.x branch ... it's a good time to improve / fix any interfaces. I don't think this one is easy :) - there's a lot of information to handle (the extra metadata needed by the parser, the image that's created (or null), and the parse-errors, and separately the parse-log), but now is a good time to come up with a cleaner alternative if you have one in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants