Skip to content

Commit

Permalink
bugfix: BUG IN CLIENT OF LIBDISPATCH: Release of an inactive object
Browse files Browse the repository at this point in the history
  • Loading branch information
haowenwu committed Sep 28, 2020
1 parent e07742b commit d26c4b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion MTHawkeye/EnergyPlugins/CPUTrace/Core/MTHCPUTrace.mm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ - (void)changeTimerIntervalTo:(CGFloat)timerIntervalInSec {

- (void)stopTimerIfNeed {
if (self.cpuTracingTimer) {
dispatch_source_cancel(self.cpuTracingTimer);
__block dispatch_source_t strongTimer = self.cpuTracingTimer;
dispatch_source_set_cancel_handler(self.cpuTracingTimer, ^{
strongTimer = nil; // dealloc the timer until it is cancelled
});
dispatch_source_cancel(self.cpuTracingTimer); // this is asyncronously
self.cpuTracingTimer = nil;
}
}
Expand Down

0 comments on commit d26c4b5

Please sign in to comment.