1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Fix leaked window error in FolderList

Observed after wiping data and then tapping a launcher shortcut
for an account.
This commit is contained in:
Joe Steele 2014-07-15 12:16:05 -04:00
parent fe49a5f005
commit 41570e4305

View File

@ -99,6 +99,8 @@ public class FolderList extends K9ListActivity {
private TextView mActionBarSubTitle; private TextView mActionBarSubTitle;
private TextView mActionBarUnread; private TextView mActionBarUnread;
private boolean mIsFinished = false;
class FolderListHandler extends Handler { class FolderListHandler extends Handler {
public void refreshTitle() { public void refreshTitle() {
@ -277,10 +279,18 @@ public class FolderList extends K9ListActivity {
mInflater = getLayoutInflater(); mInflater = getLayoutInflater();
onNewIntent(getIntent());
context = this; 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); ChangeLog cl = new ChangeLog(this);
if (cl.isFirstRun()) { if (cl.isFirstRun()) {
cl.getLogDialog().show(); cl.getLogDialog().show();
@ -308,7 +318,12 @@ public class FolderList extends K9ListActivity {
mAccount = Preferences.getPreferences(this).getAccount(accountUuid); mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
if (mAccount == null) { 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(); finish();
return; return;
} }
@ -316,6 +331,7 @@ public class FolderList extends K9ListActivity {
if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) && if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false) &&
!K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) { !K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) {
onOpenFolder(mAccount.getAutoExpandFolderName()); onOpenFolder(mAccount.getAutoExpandFolderName());
mIsFinished = true;
finish(); finish();
} else { } else {
initializeActivityView(); initializeActivityView();