0

[ios] Fixes a crash in Bookmarks.

If the bookmarks UI was displayed before the BookmarkModel was done
loading, we would incorrectly cache a pointer to a BookmarkNode that had
been destroyed.  Instead, do not set the root node of the
BookmarkHomeViewController until after the model has finished loading.

BUG=839883
TEST=See repro steps in bug. Displaying the Bookmarks UI immediately upon startup should not crash.

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I062171c6d588da6be666b92e0c961abb90f1af17
Reviewed-on: https://chromium-review.googlesource.com/1044353
Reviewed-by: Sergio Collazos <sczs@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556101}
This commit is contained in:
Rohit Rao
2018-05-04 17:33:37 +00:00
committed by Commit Bot
parent 29b7438f6d
commit 56a1674641
2 changed files with 10 additions and 1 deletions

@ -584,6 +584,9 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
if (![self isViewLoaded])
return;
DCHECK(!_rootNode);
[self setRootNode:self.bookmarks->root_node()];
int64_t unusedFolderId;
double unusedScrollPosition;
// Bookmark Model is loaded after presenting Bookmarks, we need to check

@ -175,7 +175,13 @@ using bookmarks::BookmarkNode;
dispatcher:self.dispatcher];
self.bookmarkBrowser.homeDelegate = self;
[self.bookmarkBrowser setRootNode:self.bookmarkModel->root_node()];
// Set the root node if the model has been loaded. If the model has not been
// loaded yet, the root node will be set in BookmarkHomeViewController after
// the model is finished loading.
if (self.bookmarkModel->loaded()) {
[self.bookmarkBrowser setRootNode:self.bookmarkModel->root_node()];
}
int64_t unusedFolderId;
double unusedScrollPosition;
// If cache is present then reconstruct the last visited bookmark from