From: Vadim Zeitlin Date: Fri, 20 Jul 2001 01:00:21 +0000 (+0000) Subject: filter out garbage Windows sends us via LVN_ODCACHEHINT X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e623926d636cf2ff8a39ec0b773028779189cb92 filter out garbage Windows sends us via LVN_ODCACHEHINT git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11115 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index c64d714f58..59abe4c9c5 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1621,8 +1621,22 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) const NM_CACHEHINT *cacheHint = (NM_CACHEHINT *)lParam; eventType = wxEVT_COMMAND_LIST_CACHE_HINT; - event.m_oldItemIndex = cacheHint->iFrom; - event.m_itemIndex = cacheHint->iTo; + + // we get some really stupid cache hints like ones for items in + // range 0..0 for an empty control or, after deleting an item, + // for items in invalid range - filter this garbage out + if ( cacheHint->iFrom < cacheHint->iTo ) + { + event.m_oldItemIndex = cacheHint->iFrom; + + long iMax = GetItemCount(); + event.m_itemIndex = cacheHint->iTo < iMax ? cacheHint->iTo + : iMax - 1; + } + else + { + return FALSE; + } } break;