diff options
| author | Mathew Inwood <mathewi@google.com> | 2011-09-02 12:03:26 +0100 |
|---|---|---|
| committer | Mathew Inwood <mathewi@google.com> | 2011-09-02 12:04:14 +0100 |
| commit | e09305e4ad0430571efb8ae880762204ddeaeb33 (patch) | |
| tree | 2893599cea48b305e3cd1a36c1417c959584dd3c | |
| parent | 86b396488290c22dd769f5fe3e6ad00eb8f674af (diff) | |
| download | packages_apps_Browser-e09305e4ad0430571efb8ae880762204ddeaeb33.tar.gz packages_apps_Browser-e09305e4ad0430571efb8ae880762204ddeaeb33.tar.bz2 packages_apps_Browser-e09305e4ad0430571efb8ae880762204ddeaeb33.zip | |
Make sure preloaded tabs have unique IDs.
Bug: 5251821
Change-Id: I6dd7561a2461805912268a5faf967199cf39fd8c
| -rw-r--r-- | src/com/android/browser/Controller.java | 1 | ||||
| -rw-r--r-- | src/com/android/browser/Tab.java | 9 | ||||
| -rw-r--r-- | src/com/android/browser/TabControl.java | 6 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index ff1ad0ea9..67c42ddfd 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -2168,6 +2168,7 @@ public class Controller } } Tab t = tabControl.getTab(); + t.refreshIdAfterPreload(); mTabControl.addPreloadedTab(t); addTab(t); setActiveTab(t); diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 69213cd56..3b283cc2d 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -1435,6 +1435,15 @@ class Tab implements PictureListener { }; } + /** + * This is used to get a new ID when the tab has been preloaded, before it is displayed and + * added to TabControl. Preloaded tabs can be created before restoreInstanceState, leading + * to overlapping IDs between the preloaded and restored tabs. + */ + public void refreshIdAfterPreload() { + mId = TabControl.getNextId(); + } + public void updateShouldCaptureThumbnails() { if (mWebViewController.shouldCaptureThumbnails()) { synchronized (Tab.this) { diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index 932a81169..0668b7445 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -170,6 +170,12 @@ class TabControl { } void addPreloadedTab(Tab tab) { + for (Tab current : mTabs) { + if (current != null && current.getId() == tab.getId()) { + throw new IllegalStateException("Tab with id " + tab.getId() + " already exists: " + + current.toString()); + } + } mTabs.add(tab); tab.setController(mController); mController.onSetWebView(tab, tab.getWebView()); |
