Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2690033002: Set fromEntry to nil after discardNonCommittedItems. (Closed)
Patch Set: set fromEntry to nil after discardNonCommittedItems Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 19a95a60e53e49fa95a2123711e9f9f759feb4a8..c695bf76f977afd25079aba11cdf90c0ca095d15 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -2164,6 +2164,14 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
[self webWillFinishHistoryNavigationFromEntry:fromEntry];
[self updateHTML5HistoryState];
} else {
+ // TODO(crbug.com/691492): After discardNonCommittedItems, the item
+ // pointed by |fromEntry| may not be valid anymore.
+ // Set |fromEntry| to nil to avoid crash whan using the item.
+ // Remove when the fix is not needed anymore.
+ if ([fromEntry isEqual:sessionController.transientEntry] ||
+ [fromEntry isEqual:sessionController.pendingEntry]) {
+ fromEntry = nil;
+ }
[sessionController discardNonCommittedItems];
[sessionController setPendingItemIndex:index];
@@ -2401,7 +2409,10 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
}
- (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
- DCHECK(fromEntry);
+ // TODO(crbug.com/691492): Removing the DCHECK as |fromEntry| may be nil if
+ // the pending entry was discarded.
+ // Remove when the fix is not needed anymore.
+ // DCHECK(fromEntry);
[self updateDesktopUserAgentForEntry:self.currentSessionEntry
fromEntry:fromEntry];
[_delegate webWillFinishHistoryNavigationFromEntry:fromEntry];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698