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();