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:
@@ -158,6 +158,7 @@ wxMSW:
|
|||||||
- Don't send events for already selected radio popup menu items (Kinaou Hervé).
|
- Don't send events for already selected radio popup menu items (Kinaou Hervé).
|
||||||
- wxListCtrl::GetItemCount() in wxEVT_LIST_INSERT_ITEM is no longer off by 1.
|
- wxListCtrl::GetItemCount() in wxEVT_LIST_INSERT_ITEM is no longer off by 1.
|
||||||
- Don't send bogus root selection events when clicking wxTreeCtrl (sbrowne).
|
- Don't send bogus root selection events when clicking wxTreeCtrl (sbrowne).
|
||||||
|
- Avoid bogus assert after calling wxDatePickerCtrl::SetRange().
|
||||||
|
|
||||||
wxOSX/Cocoa:
|
wxOSX/Cocoa:
|
||||||
|
|
||||||
|
@@ -60,6 +60,9 @@ protected:
|
|||||||
virtual bool MSWAllowsNone() const { return HasFlag(wxDP_ALLOWNONE); }
|
virtual bool MSWAllowsNone() const { return HasFlag(wxDP_ALLOWNONE); }
|
||||||
virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch);
|
virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDateTime MSWGetControlValue() const;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl);
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -138,9 +138,8 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
|
|||||||
m_date.ResetTime();
|
m_date.ResetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDateTime wxDatePickerCtrl::GetValue() const
|
wxDateTime wxDatePickerCtrl::MSWGetControlValue() const
|
||||||
{
|
{
|
||||||
#if wxDEBUG_LEVEL
|
|
||||||
wxDateTime dt;
|
wxDateTime dt;
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID )
|
if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID )
|
||||||
@@ -148,6 +147,14 @@ wxDateTime wxDatePickerCtrl::GetValue() const
|
|||||||
dt.SetFromMSWSysDate(st);
|
dt.SetFromMSWSysDate(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDateTime wxDatePickerCtrl::GetValue() const
|
||||||
|
{
|
||||||
|
#if wxDEBUG_LEVEL
|
||||||
|
const wxDateTime dt = MSWGetControlValue();
|
||||||
|
|
||||||
wxASSERT_MSG( m_date.IsValid() == dt.IsValid() &&
|
wxASSERT_MSG( m_date.IsValid() == dt.IsValid() &&
|
||||||
(!dt.IsValid() || dt == m_date),
|
(!dt.IsValid() || dt == m_date),
|
||||||
wxT("bug in wxDateTimePickerCtrl: m_date not in sync") );
|
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) )
|
if ( !DateTime_SetRange(GetHwnd(), flags, st) )
|
||||||
{
|
{
|
||||||
wxLogDebug(wxT("DateTime_SetRange() failed"));
|
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
|
bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const
|
||||||
|
Reference in New Issue
Block a user