Assert on invalid date in wxCalendarCtrl::SetDate() in all ports

This was done in wxMSW and wxQt but not in the native GTK+ nor the
generic version, even though they still asserted when actually trying to
use the invalid parameter later.

Make things more clear and consistent by asserting immediately and also
document the behaviour more clearly.
This commit is contained in:
Vadim Zeitlin 2018-07-25 20:16:44 +02:00
parent d553859812
commit e3a728d637
3 changed files with 7 additions and 2 deletions

View File

@ -469,7 +469,8 @@ public:
The @a date parameter must be valid and in the currently valid range as The @a date parameter must be valid and in the currently valid range as
set by SetDateRange(), otherwise the current date is not changed and set by SetDateRange(), otherwise the current date is not changed and
the function returns @false. the function returns @false and, additionally, triggers an assertion
failure if the date is invalid.
*/ */
virtual bool SetDate(const wxDateTime& date); virtual bool SetDate(const wxDateTime& date);

View File

@ -434,6 +434,8 @@ bool wxGenericCalendarCtrl::EnableMonthChange(bool enable)
bool wxGenericCalendarCtrl::SetDate(const wxDateTime& date) bool wxGenericCalendarCtrl::SetDate(const wxDateTime& date)
{ {
wxCHECK_MSG( date.IsValid(), false, "invalid date" );
bool retval = true; bool retval = true;
bool sameMonth = m_date.GetMonth() == date.GetMonth(), bool sameMonth = m_date.GetMonth() == date.GetMonth(),

View File

@ -198,7 +198,9 @@ bool wxGtkCalendarCtrl::EnableMonthChange(bool enable)
bool wxGtkCalendarCtrl::SetDate(const wxDateTime& date) bool wxGtkCalendarCtrl::SetDate(const wxDateTime& date)
{ {
if ( date.IsValid() && !IsInValidRange(date) ) wxCHECK_MSG( date.IsValid(), false, "invalid date" );
if ( !IsInValidRange(date) )
return false; return false;
g_signal_handlers_block_by_func(m_widget, g_signal_handlers_block_by_func(m_widget,