From 3cc2a299a3ac40b99703cdafe6b156510ead4fb2 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 10 Jul 2017 21:04:01 +0100 Subject: [PATCH] frmEventEditor: Don't setup new empty event if saving failed --- source/forms/eventeditor/frmEventEditor.cpp | 13 +++++++++---- source/forms/eventeditor/frmEventEditor.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/forms/eventeditor/frmEventEditor.cpp b/source/forms/eventeditor/frmEventEditor.cpp index dda8dd1..090f53f 100644 --- a/source/forms/eventeditor/frmEventEditor.cpp +++ b/source/forms/eventeditor/frmEventEditor.cpp @@ -159,7 +159,10 @@ void frmEventEditor::SaveContact(wxCommandEvent &event){ void frmEventEditor::SaveNewContact(wxCommandEvent &event){ - SaveContact(); + if (!SaveContact()) + { + return; + } // Reset the form for a new entry. @@ -180,14 +183,14 @@ void frmEventEditor::SaveNewContact(wxCommandEvent &event){ } -void frmEventEditor::SaveContact(){ +bool frmEventEditor::SaveContact(){ // Verify that a calendar has been selected. if (cmbCalendar->GetSelection() == -1 && editMode == false){ wxMessageBox("Please select a calendar for this entry.", "No calendar selected", wxOK); - return; + return false; } @@ -196,7 +199,7 @@ void frmEventEditor::SaveContact(){ if (txtEventName->GetValue().IsEmpty()){ wxMessageBox("The event name cannot be left empty.", "Event name is empty", wxOK); - return; + return false; } @@ -357,6 +360,8 @@ void frmEventEditor::SaveContact(){ } + return true; + } void frmEventEditor::CloseWindow(wxCommandEvent &event) diff --git a/source/forms/eventeditor/frmEventEditor.h b/source/forms/eventeditor/frmEventEditor.h index dca82a0..ef37eb1 100644 --- a/source/forms/eventeditor/frmEventEditor.h +++ b/source/forms/eventeditor/frmEventEditor.h @@ -56,7 +56,7 @@ class frmEventEditor : public frmEventEditorADT int calendarID = 0; int windowID = 0; string eventFilePath; - void SaveContact(); + bool SaveContact(); XCALPreferences *preferences; void SetDefaultDateTime(); void UpdateWindowName(); -- 2.39.5