From 41570e4305469218fe1357a748beac8991ce133c Mon Sep 17 00:00:00 2001 From: Joe Steele Date: Tue, 15 Jul 2014 12:16:05 -0400 Subject: [PATCH] Fix leaked window error in FolderList Observed after wiping data and then tapping a launcher shortcut for an account. --- src/com/fsck/k9/activity/FolderList.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index 15273145b..bd049bd52 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -99,6 +99,8 @@ public class FolderList extends K9ListActivity { private TextView mActionBarSubTitle; private TextView mActionBarUnread; + private boolean mIsFinished = false; + class FolderListHandler extends Handler { public void refreshTitle() { @@ -277,10 +279,18 @@ public class FolderList extends K9ListActivity { mInflater = getLayoutInflater(); - onNewIntent(getIntent()); - context = this; + onNewIntent(getIntent()); + if (mIsFinished) { + /* + * onNewIntent() may call finish(), but execution will still continue here. + * We return now because we don't want to display the changelog which can + * result in a leaked window error. + */ + return; + } + ChangeLog cl = new ChangeLog(this); if (cl.isFirstRun()) { cl.getLogDialog().show(); @@ -308,7 +318,12 @@ public class FolderList extends K9ListActivity { mAccount = Preferences.getPreferences(this).getAccount(accountUuid); if (mAccount == null) { - // This shouldn't normally happen. But apparently it does. See issue 2261. + /* + * This can happen when a launcher shortcut is created for an + * account, and then the account is deleted or data is wiped, and + * then the shortcut is used. + */ + mIsFinished = true; finish(); return; } @@ -316,6 +331,7 @@ public class FolderList extends K9ListActivity { if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) && !K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) { onOpenFolder(mAccount.getAutoExpandFolderName()); + mIsFinished = true; finish(); } else { initializeActivityView();