SVGKit/SVGKit — pull request #228 by dgileadi (2014-10-20 18:46:46+00:00)
Title: Fix KVO-related crashes in SVGKFastImageView when setting the .image property

I'm creating an SVGKFastImageView and setting its .image property instead of passing a SVGKImage to its initializer. When the SVGKImageView is later deallocated I get KVO-related crashes, saying it couldn't remove an observer that was never added. This patch fixes the issue for me on iOS 8, although based on the code I suspect the same problems would happen on earlier versions of iOS. The fix is to register all the observers in setImage instead of in populateFromImage, so that they're always registered when dealloc tries to unregister them. The dealloc method also changes to not call setImage (which would re-register them again), and instead releases the _image field directly.

The other change that is required for me to not crash on iOS 8 is to un-comment removing the "DOMTree.viewport" observer in SVGKImage, but that's not part of this pull request because I saw there's a separate issue for it.