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

Make sure draft id points to a valid message before deleting it

Avoids IllegalArgumentException in LocalStore.getMessage()
This commit is contained in:
cketti 2012-01-26 00:37:25 +01:00
parent aae734c175
commit 5a8ddaa039
2 changed files with 8 additions and 5 deletions

View File

@ -2988,9 +2988,10 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
MessagingController.getInstance(getApplication()).sendMessage(mAccount, message, null); MessagingController.getInstance(getApplication()).sendMessage(mAccount, message, null);
if (mDraftId != INVALID_DRAFT_ID) { long draftId = mDraftId;
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftId); if (draftId != INVALID_DRAFT_ID) {
mDraftId = INVALID_DRAFT_ID; mDraftId = INVALID_DRAFT_ID;
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, draftId);
} }
return null; return null;

View File

@ -3311,9 +3311,11 @@ public class MessagingController implements Runnable {
localFolder = localStore.getFolder(account.getDraftsFolderName()); localFolder = localStore.getFolder(account.getDraftsFolderName());
localFolder.open(OpenMode.READ_WRITE); localFolder.open(OpenMode.READ_WRITE);
String uid = localFolder.getMessageUidById(id); String uid = localFolder.getMessageUidById(id);
Message message = localFolder.getMessage(uid); if (uid != null) {
if (message != null) { Message message = localFolder.getMessage(uid);
deleteMessages(new Message[] { message }, null); if (message != null) {
deleteMessages(new Message[] { message }, null);
}
} }
} catch (MessagingException me) { } catch (MessagingException me) {
addErrorMessage(account, null, me); addErrorMessage(account, null, me);