Skip to content

Commit

Permalink
fix(_DTXTimerTrampoline): Correct removal of display link associated …
Browse files Browse the repository at this point in the history
…object
  • Loading branch information
ball-hayden committed Apr 18, 2022
1 parent 9a8d925 commit 6571ef0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions DetoxSync/DetoxSync/Utils/_DTXTimerTrampoline.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ - (void)dealloc
{
NSLog(@"🤦‍♂️ trampoline dealloc: %@ (tracking: %d)", self, _tracking);

objc_setAssociatedObject(_timer, __DTXTimerTrampolineKey, nil, OBJC_ASSOCIATION_RETAIN);
if(_timer)
{
objc_setAssociatedObject(_timer, __DTXTimerTrampolineKey, nil, OBJC_ASSOCIATION_ASSIGN);
}

if(_displayLink)
{
objc_setAssociatedObject(_displayLink, __DTXTimerTrampolineKey, nil, OBJC_ASSOCIATION_ASSIGN);
}
}

- (void)setTimer:(NSTimer*)timer
Expand All @@ -105,7 +113,7 @@ - (void)setTimer:(NSTimer*)timer
- (void)setDisplayLink:(CADisplayLink*)displayLink
{
_displayLink = displayLink;
objc_setAssociatedObject(_displayLink, __DTXTimerTrampolineKey, self, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject(_displayLink, __DTXTimerTrampolineKey, self, OBJC_ASSOCIATION_RETAIN);

#if DEBUG
_history = [NSString stringWithFormat:@"%@\n%@", _history, [displayLink debugDescription]];
Expand Down

0 comments on commit 6571ef0

Please sign in to comment.