summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMathew Inwood <mathewi@google.com>2011-09-02 12:03:26 +0100
committerMathew Inwood <mathewi@google.com>2011-09-02 12:04:14 +0100
commite09305e4ad0430571efb8ae880762204ddeaeb33 (patch)
tree2893599cea48b305e3cd1a36c1417c959584dd3c /src/com
parent86b396488290c22dd769f5fe3e6ad00eb8f674af (diff)
downloadpackages_apps_Browser-e09305e4ad0430571efb8ae880762204ddeaeb33.zip
packages_apps_Browser-e09305e4ad0430571efb8ae880762204ddeaeb33.tar.gz
packages_apps_Browser-e09305e4ad0430571efb8ae880762204ddeaeb33.tar.bz2
Make sure preloaded tabs have unique IDs.
Bug: 5251821 Change-Id: I6dd7561a2461805912268a5faf967199cf39fd8c
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/browser/Controller.java1
-rw-r--r--src/com/android/browser/Tab.java9
-rw-r--r--src/com/android/browser/TabControl.java6
3 files changed, 16 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index ff1ad0e..67c42dd 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 69213cd..3b283cc 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 932a811..0668b74 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());