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

Retain CGColorRefs #115

Merged
merged 1 commit into from
Mar 19, 2018
Merged

Retain CGColorRefs #115

merged 1 commit into from
Mar 19, 2018

Conversation

cysp
Copy link
Contributor

@cysp cysp commented Mar 18, 2018

I was seeing some strange behaviour where setting the colours prior to loading an SVG seemed to just ignore any colours that I had set, but only for non-default colours (i.e. colours created from their rgb component values, not UIColor.redColor).
I tracked this down to the CGColorRef objects not being retained by these property setters.
TBH I"m surprised that the result was just "not using the colour" rather than a crash of some description, but ¯\(ツ)

Copy link
Member

@fjolnir fjolnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! I just have one stylistic change I'd like you to make (commented).

SVGLayer.m Outdated
_fillColor = aColor;
CGColorRef previousColor = _fillColor;
_fillColor = CGColorRetain(aColor);
CGColorRelease(previousColor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nitpicking, but I'm very allergic to unnecessary variables. And writing it like below would eliminate the need for one:

CGColorRetain(aColor);
CGColorRelease(_fillColor);
_fillColor = aColor;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@fjolnir fjolnir merged commit 350feea into pocketsvg:master Mar 19, 2018
@fjolnir
Copy link
Member

fjolnir commented Mar 19, 2018

Thanks!

@cysp cysp deleted the bugfix/retain-cgcolors branch March 19, 2018 03:44
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