Fix assert on wxCalendarCtrl creation under Windows 7.
Unlike previous versions of Windows, 7 includes the time component in the return value of MonthCal_GetCurSel() and because of it the comparison with m_date (which doesn't have any time part) fails. Fix this by comparing just the date parts of the two wxDateTime objects. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63560 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -262,11 +262,11 @@ wxCalendarCtrl::HitTest(const wxPoint& pos,
|
|||||||
bool wxCalendarCtrl::SetDate(const wxDateTime& dt)
|
bool wxCalendarCtrl::SetDate(const wxDateTime& dt)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( dt.IsValid(), false, "invalid date" );
|
wxCHECK_MSG( dt.IsValid(), false, "invalid date" );
|
||||||
wxDateTime newdt(dt);
|
|
||||||
newdt.ResetTime();
|
const wxDateTime date = dt.GetDateOnly();
|
||||||
|
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
newdt.GetAsMSWSysTime(&st);
|
date.GetAsMSWSysTime(&st);
|
||||||
if ( !MonthCal_SetCurSel(GetHwnd(), &st) )
|
if ( !MonthCal_SetCurSel(GetHwnd(), &st) )
|
||||||
{
|
{
|
||||||
wxLogDebug(wxT("DateTime_SetSystemtime() failed"));
|
wxLogDebug(wxT("DateTime_SetSystemtime() failed"));
|
||||||
@@ -274,7 +274,7 @@ bool wxCalendarCtrl::SetDate(const wxDateTime& dt)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_date = newdt;
|
m_date = date;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,12 @@ wxDateTime wxCalendarCtrl::GetDate() const
|
|||||||
|
|
||||||
wxDateTime dt(st);
|
wxDateTime dt(st);
|
||||||
|
|
||||||
wxASSERT_MSG( dt == m_date, "mismatch between data and control" );
|
// Windows XP and earlier didn't include the time component into the
|
||||||
|
// returned date but Windows 7 does, so we can't compare the full objects
|
||||||
|
// in the same way under all the Windows versions, just compare their date
|
||||||
|
// parts
|
||||||
|
wxASSERT_MSG( dt.GetDateOnly() == m_date.GetDateOnly(),
|
||||||
|
"mismatch between data and control" );
|
||||||
#endif // wxDEBUG_LEVEL
|
#endif // wxDEBUG_LEVEL
|
||||||
|
|
||||||
return m_date;
|
return m_date;
|
||||||
|
Reference in New Issue
Block a user