Fix block based crashes when deallocating an instance of PSStackedViewController. #7

Merged
merged 2 commits into from Nov 3, 2011

Conversation

Projects
None yet
2 participants
Contributor

vickeryj commented Nov 3, 2011

I figure PSStackedViewController are not usually deallocated, but I was messing around and stuck one in a modal view controller, and it crashed when I dismissed it. A little poking around found that the cause stemmed from memory management related to blocks used in animations.

Hopefully my commits are pretty clean and the messages are clear, but if you have any questions or suggestions I would be happy to answer them or rework the commits.

vickeryj added some commits Nov 3, 2011

@vickeryj vickeryj When animation is disabled, don't remove lastController from the iVar…
… list of viewControllers_ before finishBlock is instantiated, otherwise lastController will be deallocated, and finishBlock will hold a reference to a deallocated object at the time that it is instantiated.
f77607a
@vickeryj vickeryj When alignStackAnimated:NO is called instead of running an animation …
…block with a zero duration, skip the animation block entirely. This is important as alignStackAnimated gets called indirectly when a PSStackedViewController is deallocated which will result in blocks being evaluated after deallocation, which means crashes on self references.
bae6cb2

@steipete steipete added a commit that referenced this pull request Nov 3, 2011

@steipete steipete Merge pull request #7 from vickeryj/master
Fix block based crashes when deallocating an instance of PSStackedViewController.
c6d9588

@steipete steipete merged commit c6d9588 into steipete:master Nov 3, 2011

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