From b01d7c25a08c189e40db94bbb84762286d66540a Mon Sep 17 00:00:00 2001 From: Abhishek Banthia Date: Wed, 1 Jun 2016 19:35:59 -0400 Subject: [PATCH] Deallocation bug fix. --- .../Preferences/CLPreferencesViewController.m | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Clocker/Preferences/CLPreferencesViewController.m b/Clocker/Preferences/CLPreferencesViewController.m index bdf9f9b..7f90699 100644 --- a/Clocker/Preferences/CLPreferencesViewController.m +++ b/Clocker/Preferences/CLPreferencesViewController.m @@ -91,13 +91,17 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; // Do view setup here. NSUserDefaultsController *defaults = [NSUserDefaultsController sharedUserDefaultsController]; - self.recorderControl.delegate = self; + [self.recorderControl bind:NSValueBinding toObject:defaults withKeyPath:@"values.globalPing" options:nil]; + self.recorderControl.delegate = self; - [defaults addObserver:self forKeyPath:@"values.globalPing" options:NSKeyValueObservingOptionInitial context:NULL]; + [defaults addObserver:self + forKeyPath:@"values.globalPing" + options:NSKeyValueObservingOptionInitial + context:NULL]; } /* @@ -132,12 +136,24 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; target:self action:@selector(ping:)]; [hotKeyCenter registerHotKey:newHotKey]; + } } else [super observeValueForKeyPath:aKeyPath ofObject:anObject change:aChange context:aContext]; } +- (BOOL)shortcutRecorderShouldBeginRecording:(SRRecorderControl *)aRecorder +{ + [[PTHotKeyCenter sharedCenter] pause]; + return YES; +} + +- (void)shortcutRecorderDidEndRecording:(SRRecorderControl *)aRecorder +{ + [[PTHotKeyCenter sharedCenter] resume]; +} + -(IBAction)ping:(id)sender { ApplicationDelegate *delegate = (ApplicationDelegate *)[[NSApplication sharedApplication] delegate]; @@ -148,6 +164,10 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?"; { [[NSNotificationCenter defaultCenter] removeObserver:self name:CLCustomLabelChangedNotification object:nil]; + + [[NSUserDefaultsController sharedUserDefaultsController] + removeObserver:self forKeyPath:@"values.globalPing"]; + }