Commit eab3b960 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Stops updating CBDTableVC if not visible.

ClearBrowsingDataManager causes a cell reload on CBDTableVC.
A crash was happening since this reload was occuring before
the TableView was properly loaded, this CL prevents those
updates. Once the TableView load it will use the latest
model, so there's no need for that reload.

Bug: 873929
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I9f50fbd039d3572895d5424a7ad1855e414ffb62
Reviewed-on: https://chromium-review.googlesource.com/1175106
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584175}
parent 8792a1cb
......@@ -56,6 +56,11 @@ class ChromeBrowserState;
// Modal alert for Browsing history removed dialog.
@property(nonatomic, strong) AlertCoordinator* alertCoordinator;
// The data manager might want to reload tableView cells before the tableView
// has loaded, we need to prevent this kind of updates until the tableView
// loads.
@property(nonatomic, assign) BOOL suppressTableViewUpdates;
@end
@implementation ClearBrowsingDataTableViewController
......@@ -66,6 +71,7 @@ class ChromeBrowserState;
@synthesize dataManager = _dataManager;
@synthesize dispatcher = _dispatcher;
@synthesize localDispatcher = _localDispatcher;
@synthesize suppressTableViewUpdates = _suppressTableViewUpdates;
#pragma mark - ViewController Lifecycle.
......@@ -106,7 +112,12 @@ class ChromeBrowserState;
dismissButton.accessibilityIdentifier = kSettingsDoneButtonId;
self.navigationItem.rightBarButtonItem = dismissButton;
// Do not allow any TableView updates until the model is fully loaded. The
// model might try re-loading some cells and the TableView might not be loaded
// at this point (https://crbug.com/873929).
self.suppressTableViewUpdates = YES;
[self loadModel];
self.suppressTableViewUpdates = NO;
}
- (void)loadModel {
......@@ -221,6 +232,9 @@ class ChromeBrowserState;
#pragma mark - ClearBrowsingDataConsumer
- (void)updateCellsForItem:(ListItem*)item {
if (self.suppressTableViewUpdates)
return;
// Reload the item instead of reconfiguring it. This might update
// TableViewTextLinkItems which which can have different number of lines,
// thus the cell height needs to adapt accordingly.
......
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