From 78e06eb8947ff8b2f83163f08e7726fb73ebf733 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Thu, 8 Apr 2010 11:50:58 -0700 Subject: [PATCH] Fix NPE caused by I34451000 It's unfortunate but some of the fields we cleared in I34451000 are accessed in BG threads or after the activity is destroyed. We could add != null checks everywhere, but it'll be a mess. I also think it's safer to simply remove the "= null" lines. On the other hand, clearing AsyncTasks are relatively safer because they are kept only so that we can cancel them afterwards, so I kept them. But let me know if you want to revert the original CL. Bug 2570603 Change-Id: I04a10dd7382bfcceb686c3e9af92f8949caf619e --- src/com/android/email/activity/AccountFolderList.java | 8 +++----- src/com/android/email/activity/MailboxList.java | 3 --- src/com/android/email/activity/MessageCompose.java | 5 ----- src/com/android/email/activity/MessageList.java | 3 --- src/com/android/email/activity/MessageView.java | 3 --- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/com/android/email/activity/AccountFolderList.java b/src/com/android/email/activity/AccountFolderList.java index cdd35cebc..dd88207fe 100644 --- a/src/com/android/email/activity/AccountFolderList.java +++ b/src/com/android/email/activity/AccountFolderList.java @@ -214,11 +214,9 @@ public class AccountFolderList extends ListActivity implements OnItemClickListen Utility.cancelTask(mDeleteAccountTask, false); // Don't interrupt if it's running. mDeleteAccountTask = null; - mListAdapter.changeCursor(null); - mListAdapter = null; - - mHandler = null; - mControllerCallback = null; + if (mListAdapter != null) { + mListAdapter.changeCursor(null); + } } public void onItemClick(AdapterView parent, View view, int position, long id) { diff --git a/src/com/android/email/activity/MailboxList.java b/src/com/android/email/activity/MailboxList.java index f159818ea..aa8f20507 100644 --- a/src/com/android/email/activity/MailboxList.java +++ b/src/com/android/email/activity/MailboxList.java @@ -199,9 +199,6 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On mMessageCountTask = null; mListAdapter.changeCursor(null); - mListAdapter = null; - mHandler = null; - mControllerCallback = null; } public void onClick(View v) { diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index 498732ba6..acad6cdf7 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -396,18 +396,13 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus if (mAddressAdapterTo != null) { mAddressAdapterTo.changeCursor(null); - mAddressAdapterTo = null; } if (mAddressAdapterCc != null) { mAddressAdapterCc.changeCursor(null); - mAddressAdapterCc = null; } if (mAddressAdapterBcc != null) { mAddressAdapterBcc.changeCursor(null); - mAddressAdapterBcc = null; } - mHandler = null; - mListener = null; } /** diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index a6ed1542d..4d51dea6c 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -328,9 +328,6 @@ public class MessageList extends ListActivity implements OnItemClickListener, On mSetFooterTask = null; mListAdapter.changeCursor(null); - mListAdapter = null; - mHandler = null; - mControllerCallback = null; } @Override diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java index fde92b082..aab0ff671 100644 --- a/src/com/android/email/activity/MessageView.java +++ b/src/com/android/email/activity/MessageView.java @@ -502,9 +502,6 @@ public class MessageView extends Activity implements OnClickListener { mMessageContentView = null; } // the cursor was closed in onPause() - - mHandler = null; - mControllerCallback = null; } private void onDelete() {