Skip to content

Commit ea7b64b

Browse files
author
spqchan
committed
[Mac] Fix for AutofillPopupViewBridge Crash
Unsubscribe the WebTextfieldTouchBarController from the notification center when it's deallocated or the window it's observing is closed. (cherry picked from commit 33fe231) Bug: 747713 Change-Id: I9d3543775fadc9fda31f6de83c1b962218ce0a30 Reviewed-on: https://chromium-review.googlesource.com/583929 Commit-Queue: Sarah Chan <[email protected]> Reviewed-by: Avi Drissman <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#489119} Reviewed-on: https://chromium-review.googlesource.com/587288 Reviewed-by: Sarah Chan <[email protected]> Cr-Commit-Position: refs/branch-heads/3163@{#64} Cr-Branched-From: ff259ba-refs/heads/master@{#488528}
1 parent f65d1cd commit ea7b64b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

chrome/browser/ui/cocoa/web_textfield_touch_bar_controller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
@interface WebTextfieldTouchBarController : NSObject<NSTouchBarDelegate> {
2020
TabContentsController* owner_; // weak.
2121
AutofillPopupViewCocoa* popupView_; // weak.
22+
NSWindow* window_; // weak.
2223
}
2324

2425
// Designated initializer.

chrome/browser/ui/cocoa/web_textfield_touch_bar_controller.mm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@ - (instancetype)initWithTabContentsController:(TabContentsController*)owner {
2020
return self;
2121
}
2222

23+
- (void)dealloc {
24+
[[NSNotificationCenter defaultCenter] removeObserver:self];
25+
[super dealloc];
26+
}
27+
2328
- (void)showCreditCardAutofillForPopupView:(AutofillPopupViewCocoa*)popupView {
2429
DCHECK(popupView);
2530
DCHECK([popupView window]);
31+
32+
window_ = [popupView window];
33+
2634
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
2735
[center addObserver:self
2836
selector:@selector(popupWindowWillClose:)
2937
name:NSWindowWillCloseNotification
30-
object:[popupView window]];
38+
object:window_];
3139
popupView_ = popupView;
3240

3341
if ([owner_ respondsToSelector:@selector(setTouchBar:)])
@@ -39,6 +47,11 @@ - (void)popupWindowWillClose:(NSNotification*)notif {
3947

4048
if ([owner_ respondsToSelector:@selector(setTouchBar:)])
4149
[owner_ performSelector:@selector(setTouchBar:) withObject:nil];
50+
51+
[[NSNotificationCenter defaultCenter]
52+
removeObserver:self
53+
name:NSWindowWillCloseNotification
54+
object:window_];
4255
}
4356

4457
- (NSTouchBar*)makeTouchBar {

0 commit comments

Comments
 (0)