Skip to content
Snippets Groups Projects
Commit 6dd03250 authored by George Nachman's avatar George Nachman
Browse files

Fix a retain cycle in the keys prefs view controller that caused a crash when...

Fix a retain cycle in the keys prefs view controller that caused a crash when toggling the hotkey pinned button because a vc belonging to a now-dead window got a notification that something changed and asserted trying to get the info for the control.
parent 0877eef6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -18,7 +18,8 @@
#import "PreferencePanel.h"
#import "PSMTabBarControl.h"
 
static NSString * const kHotkeyWindowGeneratedProfileNameKey = @"Hotkey Window";
static NSString *const kHotkeyWindowGeneratedProfileNameKey = @"Hotkey Window";
static NSString *const kHotkeyAutoHidesPreferenceDidChange = @"kHotkeyAutoHidesPreferenceDidChange";
 
@interface KeysPreferencesViewController () <iTermKeyMappingViewControllerDelegate>
@end
Loading
Loading
@@ -45,11 +46,20 @@ static NSString * const kHotkeyWindowGeneratedProfileNameKey = @"Hotkey Window";
IBOutlet NSPopUpButton *_hotkeyBookmark;
}
 
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)awakeFromNib {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadAddressBookNotification:)
name:kReloadAddressBookNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hotkeyAutoHidesPreferenceDidChange:)
name:kHotkeyAutoHidesPreferenceDidChange
object:nil];
PreferenceInfo *info;
 
Loading
Loading
@@ -122,17 +132,19 @@ static NSString * const kHotkeyWindowGeneratedProfileNameKey = @"Hotkey Window";
key:kPreferenceKeyHotKeyTogglesWindow
type:kPreferenceInfoTypeCheckbox];
info.onChange = ^() { [self hotkeyTogglesWindowDidChange]; };
info = [self defineControl:_hotkeyAutoHides
key:kPreferenceKeyHotkeyAutoHides
type:kPreferenceInfoTypeCheckbox];
info.onChange = ^() { [self postRefreshNotification]; };
// You can change this setting with a key binding action, so we observer it to update the
// You can change this setting with a key binding action, so we observe it to update the
// control when the user default changes.
[iTermPreferences addObserverForKey:kPreferenceKeyHotkeyAutoHides
block:^(id before, id after) {
[self updateValueForInfo:info];
}];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[iTermPreferences addObserverForKey:kPreferenceKeyHotkeyAutoHides block:^(id before, id after) {
[[NSNotificationCenter defaultCenter] postNotificationName:kHotkeyAutoHidesPreferenceDidChange
object:nil];
}];
});
 
[self defineControl:_hotkeyBookmark
key:kPreferenceKeyHotkeyProfileGuid
Loading
Loading
@@ -383,6 +395,10 @@ static NSString * const kHotkeyWindowGeneratedProfileNameKey = @"Hotkey Window";
 
#pragma mark - Notification handlers
 
- (void)hotkeyAutoHidesPreferenceDidChange:(NSNotification *)notification {
[self updateValueForInfo:[self infoForControl:_hotkeyAutoHides]];
}
- (void)reloadAddressBookNotification:(NSNotification *)aNotification {
[self populateHotKeyProfilesMenu];
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment