Avoid bogus assert after calling wxDatePickerCtrl::SetRange() in wxMSW.
If the old value didn't lie inside the new range, it was changed by the native control internally but the value stored by wxDatePickerCtrl itself remained unchanged, resulting in asserts later when the mismatch between them was detected. Closes #13189.
This commit is contained in:
@@ -138,9 +138,8 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
|
||||
m_date.ResetTime();
|
||||
}
|
||||
|
||||
wxDateTime wxDatePickerCtrl::GetValue() const
|
||||
wxDateTime wxDatePickerCtrl::MSWGetControlValue() const
|
||||
{
|
||||
#if wxDEBUG_LEVEL
|
||||
wxDateTime dt;
|
||||
SYSTEMTIME st;
|
||||
if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID )
|
||||
@@ -148,6 +147,14 @@ wxDateTime wxDatePickerCtrl::GetValue() const
|
||||
dt.SetFromMSWSysDate(st);
|
||||
}
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
wxDateTime wxDatePickerCtrl::GetValue() const
|
||||
{
|
||||
#if wxDEBUG_LEVEL
|
||||
const wxDateTime dt = MSWGetControlValue();
|
||||
|
||||
wxASSERT_MSG( m_date.IsValid() == dt.IsValid() &&
|
||||
(!dt.IsValid() || dt == m_date),
|
||||
wxT("bug in wxDateTimePickerCtrl: m_date not in sync") );
|
||||
@@ -176,7 +183,12 @@ void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
|
||||
if ( !DateTime_SetRange(GetHwnd(), flags, st) )
|
||||
{
|
||||
wxLogDebug(wxT("DateTime_SetRange() failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Setting the range could have changed the current control value if the
|
||||
// old one wasn't inside the new range, so update it.
|
||||
m_date = MSWGetControlValue();
|
||||
}
|
||||
|
||||
bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const
|
||||
|
||||
Reference in New Issue
Block a user