From aae5ec8bbe0b14bd2f43708186428e3c09d10739 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 9 May 2008 22:15:55 +0000 Subject: [PATCH] Avoid asserts when wxDP_ALLOWNONE is used and the date is set to wxDefaultDateTime git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53510 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datectlg.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 2ca382a196..a898b9eea3 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -158,6 +158,7 @@ public: if ( date.IsValid() ) { m_combo->SetText(date.Format(m_format)); + SetDate(date); } else // invalid date { @@ -166,8 +167,6 @@ public: m_combo->SetText(wxEmptyString); } - - SetDate(date); } bool ParseDateTime(const wxString& s, wxDateTime* pDt) @@ -238,6 +237,9 @@ private: m_combo->SetText(GetStringValueFor(dt)); + if ( !dt.IsValid() && HasDPFlag(wxDP_ALLOWNONE) ) + return; + // notify that we had to change the date after validation if ( (dt.IsValid() && (!dtOld.IsValid() || dt != dtOld)) || (!dt.IsValid() && dtOld.IsValid()) ) @@ -322,11 +324,9 @@ private: virtual void SetStringValue(const wxString& s) { wxDateTime dt; - if ( ParseDateTime(s, &dt) ) + if ( !s.empty() && ParseDateTime(s, &dt) ) SetDate(dt); - else if ( HasDPFlag(wxDP_ALLOWNONE) ) - SetDate(wxInvalidDateTime); - //else: !wxDP_ALLOWNONE, keep the old value + //else: keep the old value } virtual wxString GetStringValue() const