diff options
author | Patrick Scott <phanna@android.com> | 2009-08-31 09:48:37 -0400 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2009-08-31 12:49:52 -0400 |
commit | 2a67de4059775466071da52c07b18627c51c677c (patch) | |
tree | 3ddfff22f654c875da4845900cbf41b83985dcc8 /src | |
parent | 73b588c8e9b865aee5d416802b775a67e2e3aebb (diff) | |
download | packages_apps_browser-2a67de4059775466071da52c07b18627c51c677c.zip packages_apps_browser-2a67de4059775466071da52c07b18627c51c677c.tar.gz packages_apps_browser-2a67de4059775466071da52c07b18627c51c677c.tar.bz2 |
Check for null tabs before acquiring the parent tab.
This prevents a NPE when the current tab is null. This is very rare but can
still possibly happen.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/TabControl.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index efef303..037a757 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -766,7 +766,7 @@ class TabControl { if (getTabCount() == 0) return; // free the least frequently used background tab - Tab t = getLeastUsedTab(getCurrentTab().getParentTab()); + Tab t = getLeastUsedTab(getCurrentTab()); if (t != null) { Log.w(LOGTAG, "Free a tab in the browser"); freeTab(t); @@ -785,9 +785,10 @@ class TabControl { System.gc(); } - private Tab getLeastUsedTab(Tab currentParent) { - // Don't do anything if we only have 1 tab. - if (getTabCount() == 1) { + private Tab getLeastUsedTab(Tab current) { + // Don't do anything if we only have 1 tab or if the current tab is + // null. + if (getTabCount() == 1 || current == null) { return null; } @@ -802,11 +803,12 @@ class TabControl { do { t = mTabQueue.get(i++); } while (i < queueSize - && ((t != null && t.mMainView == null) || t == currentParent)); + && ((t != null && t.mMainView == null) + || t == current.mParentTab)); // Don't do anything if the last remaining tab is the current one or if // the last tab has been freed already. - if (t == getCurrentTab() || t.mMainView == null) { + if (t == current || t.mMainView == null) { return null; } |