Commit 81112286 authored by spqchan's avatar spqchan Committed by Commit Bot

[Mac] Fix for Bookmark Editor Crash

Using field editors is finicky especially when
there's multiple textfields. Using one field editor
is enough, so this CL combines the name and URL
field editors into one.

In addition, like what the
AutocompleteTextFieldEditor is doing, the field
editor's fieldEditor property will reset each time
windowWillReturnFieldEditor:toObject: is called so
that notifications will be sent properly.

Bug: 744211
Change-Id: I2367d2abc788aaf1ef3daa037c879a222440015a
Reviewed-on: https://chromium-review.googlesource.com/595214Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sarah Chan <spqchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491072}
parent a7b04f8f
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
IBOutlet NSTextField* urlField_; IBOutlet NSTextField* urlField_;
IBOutlet NSTextField* nameTextField_; IBOutlet NSTextField* nameTextField_;
// Field editors for |urlField_| and |nameTextField_|. // Field editor for |urlField_| and |nameTextField_|.
base::scoped_nsobject<DialogTextFieldEditor> urlFieldEditor_; base::scoped_nsobject<DialogTextFieldEditor> touchBarFieldEditor_;
base::scoped_nsobject<DialogTextFieldEditor> nameFieldEditor_;
} }
@property(nonatomic, copy) NSString* displayURL; @property(nonatomic, copy) NSString* displayURL;
......
...@@ -49,8 +49,7 @@ using bookmarks::BookmarkNode; ...@@ -49,8 +49,7 @@ using bookmarks::BookmarkNode;
configuration:configuration])) { configuration:configuration])) {
// "Add Page..." has no "node" so this may be NULL. // "Add Page..." has no "node" so this may be NULL.
node_ = node; node_ = node;
urlFieldEditor_.reset([[DialogTextFieldEditor alloc] init]); touchBarFieldEditor_.reset([[DialogTextFieldEditor alloc] init]);
nameFieldEditor_.reset([[DialogTextFieldEditor alloc] init]);
} }
return self; return self;
} }
...@@ -85,19 +84,14 @@ using bookmarks::BookmarkNode; ...@@ -85,19 +84,14 @@ using bookmarks::BookmarkNode;
} }
- (void)windowWillClose:(NSNotification*)notification { - (void)windowWillClose:(NSNotification*)notification {
[urlFieldEditor_ setFieldEditor:NO]; [touchBarFieldEditor_ setFieldEditor:NO];
[nameFieldEditor_ setFieldEditor:NO]; touchBarFieldEditor_.reset();
urlFieldEditor_.reset();
nameFieldEditor_.reset();
[super windowWillClose:notification]; [super windowWillClose:notification];
} }
- (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj {
if (obj == urlField_) if (obj == urlField_ || obj == nameTextField_)
return urlFieldEditor_.get(); return touchBarFieldEditor_.get();
else if (obj == nameTextField_)
return nameFieldEditor_.get();
return nil; return nil;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment