From 068bf1e11b199d57a34bc816bc168153201411db Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Tue, 30 Apr 2019 18:44:27 +0530 Subject: [PATCH] Protect form finish when activity is getting destroyed --- .../org/commcare/activities/FormEntryActivity.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/org/commcare/activities/FormEntryActivity.java b/app/src/org/commcare/activities/FormEntryActivity.java index 3637325819..8ec098b861 100644 --- a/app/src/org/commcare/activities/FormEntryActivity.java +++ b/app/src/org/commcare/activities/FormEntryActivity.java @@ -1002,12 +1002,13 @@ protected void triggerUserQuitInput() { * Call when the user is ready to save and return the current form as complete */ protected void triggerUserFormComplete() { - - if (mFormController.isFormReadOnly()) { - finishReturnInstance(false); - } else { - int formRecordId = getIntent().getIntExtra(KEY_FORM_RECORD_ID, -1); - saveCompletedFormToDisk(instanceState.getDefaultFormTitle(formRecordId)); + if(!isFinishing()) { + if (mFormController.isFormReadOnly()) { + finishReturnInstance(false); + } else { + int formRecordId = getIntent().getIntExtra(KEY_FORM_RECORD_ID, -1); + saveCompletedFormToDisk(instanceState.getDefaultFormTitle(formRecordId)); + } } }