1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -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);
if (mDraftId != INVALID_DRAFT_ID) {
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftId);
long draftId = mDraftId;
if (draftId != INVALID_DRAFT_ID) {
mDraftId = INVALID_DRAFT_ID;
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, draftId);
}
return null;

View File

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