mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-30 17:40:34 +01:00
Workaround sqlite bug
endTransaction native crash when exception
This commit is contained in:
@@ -817,20 +817,27 @@ 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);
|
||||
EntityMessage 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));
|
||||
|
||||
if (draft.to == null && draft.cc == null && draft.bcc == null)
|
||||
throw new IllegalArgumentException(context.getString(R.string.title_to_missing));
|
||||
}
|
||||
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
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");
|
||||
|
||||
Log.i(Helper.TAG, "Load action id=" + draft.id + " action=" + action);
|
||||
|
||||
// Convert data
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user