From 7f025a15c4e80816ed68cd0af03ea67efd2f8e61 Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Mon, 28 Sep 2009 16:47:25 +0200 Subject: [PATCH] MessageView: check for null mMessageContentView on access. Bug 2148358. It seems that AsyncTask.onPostExecute() can be invoked even after the task was cancelled, and after Activity.onDestroy(). --- .../android/email/activity/MessageView.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java index d17b92a2a..c85e50b03 100644 --- a/src/com/android/email/activity/MessageView.java +++ b/src/com/android/email/activity/MessageView.java @@ -190,7 +190,9 @@ public class MessageView extends Activity implements OnClickListener { break; case MSG_LOAD_CONTENT_URI: String uriString = (String) msg.obj; - mMessageContentView.loadUrl(uriString); + if (mMessageContentView != null) { + mMessageContentView.loadUrl(uriString); + } break; case MSG_SET_ATTACHMENTS_ENABLED: for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { @@ -666,7 +668,9 @@ public class MessageView extends Activity implements OnClickListener { private void onShowPictures() { if (mMessage != null) { - mMessageContentView.getSettings().setBlockNetworkImage(false); + if (mMessageContentView != null) { + mMessageContentView.getSettings().setBlockNetworkImage(false); + } mShowPicturesSection.setVisibility(View.GONE); } } @@ -763,7 +767,9 @@ public class MessageView extends Activity implements OnClickListener { } cancelAllTasks(); setTitle(""); - mMessageContentView.loadUrl("file:///android_asset/empty.html"); + if (mMessageContentView != null) { + mMessageContentView.loadUrl("file:///android_asset/empty.html"); + } mAttachments.removeAllViews(); mAttachments.setVisibility(View.GONE); mAttachmentIcon.setVisibility(View.GONE); @@ -1172,7 +1178,7 @@ public class MessageView extends Activity implements OnClickListener { addAttachment(attachment); } } - if (htmlChanged) { + if (htmlChanged && mMessageContentView != null) { mMessageContentView.loadDataWithBaseURL("email://", mHtmlText, "text/html", "utf-8", null); } @@ -1291,7 +1297,9 @@ public class MessageView extends Activity implements OnClickListener { } mShowPicturesSection.setVisibility(hasImages ? View.VISIBLE : View.GONE); - mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null); + if (mMessageContentView != null) { + mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null); + } // Ask for attachments after body mLoadAttachmentsTask = new LoadAttachmentsTask();