From d068f8015daa84296463fcc0420e40e35e40fe7d Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Mon, 22 Jun 2009 11:46:06 -0400 Subject: Fix 2 NPEs in the Browser. The first was from freeMemory getting a tab back that had already been freed. This is a really hard case to reproduce but it appears that it can happen. So just check for a null mMainView before trying to free the tab. The second was a null mTabOverview during the onAnimationStart method when animating to the tab overview. I think this is caused by message delays not being accurate enough to ensure the overview has been created. A check for null fixes the problem for now but I am working on a better solution to ensure animation message order. --- src/com/android/browser/BrowserActivity.java | 10 ++++++---- src/com/android/browser/TabControl.java | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/com') diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 8fb853f..eae24f1 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -2112,10 +2112,12 @@ public class BrowserActivity extends Activity final Animation.AnimationListener l = new Animation.AnimationListener() { public void onAnimationStart(Animation a) { - mTabOverview.requestFocus(); - // Clear the listener so we don't trigger a tab - // selection. - mTabOverview.setListener(null); + if (mTabOverview != null) { + mTabOverview.requestFocus(); + // Clear the listener so we don't trigger a tab + // selection. + mTabOverview.setListener(null); + } } public void onAnimationRepeat(Animation a) {} public void onAnimationEnd(Animation a) { diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index 581d144..575be8d 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -709,8 +709,9 @@ class TabControl { t = mTabQueue.get(i++); } while (i < queueSize && t != null && t.mMainView == null); - // Don't do anything if the last remaining tab is the current one. - if (t == getCurrentTab()) { + // 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) { return null; } -- cgit v1.1