From 7907711e82ddcd770b9688684c0249f3114300f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 14 Mar 2016 01:09:48 +0100 Subject: [PATCH] Work around assert on wxDatePickerCtrl creation due to a WINE bug Don't use invalid SYSTEMTIME returned by DateTime_GetRange() under WINE which always returns GDTR_MIN, even if the min value is not actually valid, see https://bugs.winehq.org/show_bug.cgi?id=40301 This avoids an assert which otherwise happened whenever wxDatePickerCtrl was created. --- src/msw/datectrl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/msw/datectrl.cpp b/src/msw/datectrl.cpp index 05beb336e0..d21cb60ef0 100644 --- a/src/msw/datectrl.cpp +++ b/src/msw/datectrl.cpp @@ -196,7 +196,11 @@ bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const DWORD flags = DateTime_GetRange(GetHwnd(), st); if ( dt1 ) { - if ( flags & GDTR_MIN ) + // Workaround for https://bugs.winehq.org/show_bug.cgi?id=40301: WINE + // returns GDTR_MIN even if there is no lower range bound. Luckily we + // can check for it easily as the SYSTEMTIME contains only zeroes in + // this case and 0 is invalid value for wMonth field. + if ( (flags & GDTR_MIN) && (st[0].wMonth != 0) ) dt1->SetFromMSWSysDate(st[0]); else *dt1 = wxDefaultDateTime;