Skip to content

Commit

Permalink
Fix a crash due to UIViewPropertyAnimator objects getting deallocated…
Browse files Browse the repository at this point in the history
… too early
  • Loading branch information
LeoNatan committed Mar 26, 2024
1 parent 3c25c56 commit 529cf4b
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions LNPopupController/LNPopupController/Private/LNPopupController.m
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,9 @@ - (void)_transitionToState:(LNPopupPresentationState)state notifyDelegate:(BOOL)

if(animated == NO)
{
[_runningPopupAnimation stopAnimation:NO];
[_runningPopupAnimation finishAnimationAtPosition:UIViewAnimatingPositionEnd];
UIViewPropertyAnimator* retained = _runningPopupAnimation;
[retained stopAnimation:NO];
[retained finishAnimationAtPosition:UIViewAnimatingPositionEnd];
}
}

Expand Down Expand Up @@ -1259,15 +1260,17 @@ - (void)_addEventQueueResumptionStep:(UIViewPropertyAnimator*)animator
//{
// if(_runningBarAnimation != nil)
// {
// [_runningBarAnimation stopAnimation:NO];
// [_runningBarAnimation finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
// UIViewPropertyAnimator* retained = _runningBarAnimation;
// [retained stopAnimation:NO];
// [retained finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
// _runningBarAnimation = nil;
// }
//
// if(_runningBarSidecarAnimation != nil)
// {
// [_runningBarSidecarAnimation stopAnimation:NO];
// [_runningBarSidecarAnimation finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
// UIViewPropertyAnimator* retained = _runningBarSidecarAnimation;
// [retained stopAnimation:NO];
// [retained finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
// _runningBarSidecarAnimation = nil;
// }
//}
Expand All @@ -1276,8 +1279,9 @@ - (void)_addEventQueueResumptionStep:(UIViewPropertyAnimator*)animator
//{
// if(_runningPopupAnimation != nil)
// {
// [_runningPopupAnimation stopAnimation:NO];
// [_runningPopupAnimation finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
// UIViewPropertyAnimator* retained = _runningPopupAnimation;
// [retained stopAnimation:NO];
// [retained finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
// _runningPopupAnimation = nil;
// }
//}
Expand Down Expand Up @@ -1420,11 +1424,14 @@ - (void)_presentPopupBarWithContentViewController:(UIViewController*)contentView
{
[_runningBarSidecarAnimation startAnimation];

[_runningBarAnimation stopAnimation:NO];
[_runningBarAnimation finishAnimationAtPosition:UIViewAnimatingPositionEnd];
UIViewPropertyAnimator* retained1 = _runningBarAnimation;
UIViewPropertyAnimator* retained2 = _runningBarSidecarAnimation;

[_runningBarSidecarAnimation stopAnimation:NO];
[_runningBarSidecarAnimation finishAnimationAtPosition:UIViewAnimatingPositionEnd];
[retained1 stopAnimation:NO];
[retained1 finishAnimationAtPosition:UIViewAnimatingPositionEnd];

[retained2 stopAnimation:NO];
[retained2 finishAnimationAtPosition:UIViewAnimatingPositionEnd];
}
else
{
Expand Down Expand Up @@ -1603,8 +1610,9 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple

if(animated == NO)
{
[_runningBarAnimation stopAnimation:NO];
[_runningBarAnimation finishAnimationAtPosition:UIViewAnimatingPositionEnd];
UIViewPropertyAnimator* retained = _runningBarAnimation;
[retained stopAnimation:NO];
[retained finishAnimationAtPosition:UIViewAnimatingPositionEnd];
}
};

Expand Down

0 comments on commit 529cf4b

Please sign in to comment.