From 4b0982a8208063eb3a71200a28abb30b0ef80656 Mon Sep 17 00:00:00 2001 From: Neil Coronado Date: Wed, 7 Jun 2023 21:41:48 +0000 Subject: [PATCH] [CrashFix] Add invalid tab id check Add invalid tab id check. -Believe this was getting triggered when undoing a tab closure on the a11y list switcher. (cherry picked from commit 2e949b3df6ab653ce889e996477ad807b71075ac) Bug: 1433347 Change-Id: I47b1907474423cce8f52710a35d66ccc142e0184 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4581212 Auto-Submit: Neil Coronado Commit-Queue: Neil Coronado Reviewed-by: Theresa Sullivan Cr-Original-Commit-Position: refs/heads/main@{#1152158} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4599214 Cr-Commit-Position: refs/branch-heads/5790@{#467} Cr-Branched-From: 1d71a337b1f6e707a13ae074dca1e2c34905eb9f-refs/heads/main@{#1148114} --- .../chrome/browser/tasks/tab_management/TabListMediator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java index b1d2543246e814..520d71630c56f8 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java @@ -565,7 +565,9 @@ public void didSelectTab(Tab tab, int type, int lastId) { // undo, identify the related TabIds and determine newIndex based on if any of // the related ids are present in model. newIndex = getIndexForTabWithRelatedTabs(tab); - model.updateTabListModelIdForGroup(tab, newIndex); + if (newIndex != Tab.INVALID_TAB_ID) { + model.updateTabListModelIdForGroup(tab, newIndex); + } } mLastSelectedTabListModelIndex = oldIndex;