Browse Source

Workaround sqlite bug

endTransaction native crash when exception
main
M66B 6 years ago
parent
commit
9bb3baa45f
1 changed files with 16 additions and 16 deletions
  1. +16
    -16
      app/src/main/java/eu/faircode/email/FragmentCompose.java

+ 16
- 16
app/src/main/java/eu/faircode/email/FragmentCompose.java View File

@ -817,19 +817,26 @@ public class FragmentCompose extends FragmentEx {
String subject = args.getString("subject");
String body = args.getString("body");
EntityMessage draft;
// Get draft & selected identity
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage draft = db.message().getMessage(id);
EntityIdentity identity = db.identity().getIdentity(iid);
draft = db.message().getMessage(id);
EntityIdentity identity = db.identity().getIdentity(iid);
// Draft deleted by server
if (draft == null)
throw new MessageRemovedException("Draft for action was deleted");
// Check data
if (action == R.id.action_send) {
if (draft.identity == null)
throw new IllegalArgumentException(context.getString(R.string.title_from_missing));
// Draft deleted by server
if (draft == null)
throw new MessageRemovedException("Draft for action was deleted");
if (draft.to == null && draft.cc == null && draft.bcc == null)
throw new IllegalArgumentException(context.getString(R.string.title_to_missing));
}
try {
db.beginTransaction();
Log.i(Helper.TAG, "Load action id=" + draft.id + " action=" + action);
@ -877,13 +884,6 @@ public class FragmentCompose extends FragmentEx {
db.message().updateMessage(draft);
draft.write(context, body);
// Check data
if (draft.identity == null)
throw new IllegalArgumentException(context.getString(R.string.title_from_missing));
if (draft.to == null && draft.cc == null && draft.bcc == null)
throw new IllegalArgumentException(context.getString(R.string.title_to_missing));
// Save message ID
String msgid = draft.msgid;


Loading…
Cancel
Save