Skip to content

Commit

Permalink
Fix issue MortimerGoro#216: crash when combining programmatically cre…
Browse files Browse the repository at this point in the history
…ated offset animations in consecutive block callbacks
  • Loading branch information
MortimerGoro committed Aug 27, 2016
1 parent 2cf7a42 commit 13da33f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,9 @@ -(void) animationTick: (CADisplayLink *) timer
[timer invalidate];
_displayLink = nil;
if (_animationCompletion) {
_animationCompletion(YES);
void (^callbackCopy)(BOOL finished) = _animationCompletion; //copy to avoid duplicated callbacks
_animationCompletion = nil;
callbackCopy(YES);
}
}
}
Expand All @@ -1123,8 +1124,9 @@ -(void) setSwipeOffset:(CGFloat)offset animation: (MGSwipeAnimation *) animation
_displayLink = nil;
}
if (_animationCompletion) { //notify previous animation cancelled
_animationCompletion(NO);
void (^callbackCopy)(BOOL finished) = _animationCompletion; //copy to avoid duplicated callbacks
_animationCompletion = nil;
callbackCopy(NO);
}
if (offset !=0) {
[self createSwipeViewIfNeeded];
Expand Down

0 comments on commit 13da33f

Please sign in to comment.