From 8d1a41016dc42d3d3610b72cecab6620fbc1aed8 Mon Sep 17 00:00:00 2001 From: Francesco Montorsi Date: Mon, 12 Jan 2009 19:34:42 +0000 Subject: [PATCH] assert when the item index is out of range in wxMSW's listctrl, just like generic listctrl does git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58055 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 4 ++++ tests/controls/listctrltest.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 9e23d1db3f..f05ea49fb8 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1162,6 +1162,10 @@ bool wxListCtrl::GetSubItemRect(long item, long subItem, wxRect& rect, int code) (subItem >= 0 && subItem < GetColumnCount()), false, _T("invalid sub item index") ); + // use wxCHECK_MSG against "item" too, for coherency with the generic implementation: + wxCHECK_MSG( item >= 0 && item < GetItemCount(), false, + _T("invalid item in GetSubItemRect") ); + int codeWin; if ( code == wxLIST_RECT_BOUNDS ) codeWin = LVIR_BOUNDS; diff --git a/tests/controls/listctrltest.cpp b/tests/controls/listctrltest.cpp index 6c88105420..5e615eb283 100644 --- a/tests/controls/listctrltest.cpp +++ b/tests/controls/listctrltest.cpp @@ -159,7 +159,7 @@ void ListCtrlTestCase::ItemRect() // do test wxRect r; - //CPPUNIT_ASSERT( !m_list->GetItemRect(1, r) ); this asserts as item #1 does not exist + WX_ASSERT_FAILS_WITH_ASSERT( m_list->GetItemRect(1, r) ); CPPUNIT_ASSERT( m_list->GetItemRect(0, r) ); CPPUNIT_ASSERT_EQUAL( 150, r.GetWidth() ); -- 2.45.2