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

Fix a bug where we tried to remove the window's first responder when a popover...

Fix a bug where we tried to remove the window's first responder when a popover closes, but it was done wrong because in awakeFromNib the view did not yet have a window so the workaround was a no-op. Not sure if this used to work and then something changed, breaking it. The new code should be more robust because it gets the window from the color well, which we know must exist when its popover will close. This accounted for 20% of crashes in 3.0.5.
parent 3c9fed39
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -89,7 +89,7 @@ static NSString * const kColorGalleryURL = @"https://www.iterm2.com/colorgallery
colorWell.action = @selector(settingChanged:);
colorWell.target = self;
colorWell.continuous = YES;
NSValue *weakWindowPointer = [NSValue valueWithPointer:self.view.window];
NSValue *weakViewPointer = [NSValue valueWithPointer:colorWell];
colorWell.willClosePopover = ^() {
// NSSearchField remembers who was first responder before it gained
// first responder status. That is the popover at this time. When
Loading
Loading
@@ -98,8 +98,8 @@ static NSString * const kColorGalleryURL = @"https://www.iterm2.com/colorgallery
// smart and doesn't realize the popover has been deallocated. So
// this changes its conception of who was the previous first
// responder and prevents the crash.
NSWindow *unsafeWindow = [weakWindowPointer pointerValue];
[unsafeWindow makeFirstResponder:nil];
NSView *unsafeView = [weakViewPointer pointerValue];
[unsafeView.window makeFirstResponder:nil];
};
}
 
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