Don't assert if starting search position in LVN_ODFINDITEM is invalid.

Just use wxLogDebug() if this happens, asserting here is not the right thing
to do as it doesn't indicate an error in the program but rather invalid
external input and, moreover, we can recover from it easily.

No changes in behaviour in normal case.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2011-03-09 09:28:34 +00:00
parent f382836f40
commit aab1681669

View File

@ -2391,10 +2391,25 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
// this is the first item we should examine, search from it
// wrapping if necessary
const int startPos = pFindInfo->iStart;
int startPos = pFindInfo->iStart;
const int maxPos = GetItemCount();
wxCHECK_MSG( startPos <= maxPos, false,
wxT("bad starting position in LVN_ODFINDITEM") );
// Check that the index is valid to ensure that our loop
// below always terminates.
if ( startPos < 0 || startPos >= maxPos )
{
// When the last item in the control is selected,
// iStart is really set to (invalid) maxPos index so
// accept this silently.
if ( startPos != maxPos )
{
wxLogDebug(wxT("Ignoring invalid search start ")
wxT("position %d in list control with ")
wxT("%d items."), startPos, maxPos);
}
startPos = 0;
}
int currentPos = startPos;
do