From f17747e21a80b71447654462a60fca6baaf64a17 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 14 Jan 2018 17:24:22 +0000 Subject: [PATCH] frmContactEditor: Check save was successful before closing --- source/contacteditor/frmContactEditor-Save.cpp | 11 +++++++++-- source/contacteditor/frmContactEditor.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/contacteditor/frmContactEditor-Save.cpp b/source/contacteditor/frmContactEditor-Save.cpp index baeeae5..dca32d0 100644 --- a/source/contacteditor/frmContactEditor-Save.cpp +++ b/source/contacteditor/frmContactEditor-Save.cpp @@ -33,7 +33,8 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) if (boolUnsupportedAccount == true){ - wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR); + wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR); + saveSuccess = false; return; } @@ -46,6 +47,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) if (cmbDisplayAsValue.IsEmpty()){ wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR); + saveSuccess = false; return; } @@ -566,6 +568,8 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) event2.SetClientData(ucd); wxPostEvent(MainPtr, event2); } + + saveSuccess = true; } @@ -576,6 +580,9 @@ void frmContactEditor::SaveCloseContact( wxCommandEvent& event ) wxCommandEvent NullEvent; this->SaveContact(NullEvent); - this->Close(); + if (saveSuccess) + { + this->Close(); + } } \ No newline at end of file diff --git a/source/contacteditor/frmContactEditor.h b/source/contacteditor/frmContactEditor.h index 49dd826..dbad355 100644 --- a/source/contacteditor/frmContactEditor.h +++ b/source/contacteditor/frmContactEditor.h @@ -744,6 +744,7 @@ class frmContactEditor : public frmContactEditorADT bool EditMode = FALSE; bool StartupEditMode = FALSE; bool DialogOpen = FALSE; + bool saveSuccess = false; /* std::string base64dec; -- 2.39.5