-- v5: comctl32/listview: Prevent LISTVIEW_GetNextItem failure after checking last item state in list
From: Ilia Docin ilya.docin@contentai.ru
--- dlls/comctl32/listview.c | 2 +- dlls/comctl32/tests/listview.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index c82473b6205..b7ef90635ba 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -7371,7 +7371,7 @@ static INT LISTVIEW_GetNextItem(const LISTVIEW_INFO *infoPtr, INT nItem, UINT uF { if ((infoPtr->uView == LV_VIEW_LIST) || (infoPtr->uView == LV_VIEW_DETAILS)) { - while (nItem < infoPtr->nItemCount) + while (nItem < infoPtr->nItemCount - 1) { nItem++; if ((LISTVIEW_GetItemState(infoPtr, nItem, uMask) & uMask) == uMask) diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 1081a045cde..dbe2cd574f9 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -7162,6 +7162,36 @@ static void test_LVM_SETBKIMAGE(BOOL is_v6) CoUninitialize(); }
+static void test_LVM_GETNEXTITEM(void) +{ + /* LVM_GETNEXTITEM */ + + HWND hwnd; + DWORD r; + UINT uFlagsAbove = MAKELPARAM(LVNI_ABOVE, 0); + UINT uFlagsBelow = MAKELPARAM(LVNI_BELOW, 0); + + hwnd = create_listview_control(LVS_REPORT); + insert_item(hwnd, 0); + insert_item(hwnd, 1); + insert_item(hwnd, 2); + + r = SendMessageA(hwnd, LVM_GETNEXTITEM, 0, uFlagsAbove); + expect(-1, r); + r = SendMessageA(hwnd, LVM_GETNEXTITEM, 0, uFlagsBelow); + expect(1, r); + r = SendMessageA(hwnd, LVM_GETNEXTITEM, 1, uFlagsAbove); + expect(0, r); + r = SendMessageA(hwnd, LVM_GETNEXTITEM, 1, uFlagsBelow); + expect(2, r); + r = SendMessageA(hwnd, LVM_GETNEXTITEM, 2, uFlagsAbove); + expect(1, r); + r = SendMessageA(hwnd, LVM_GETNEXTITEM, 2, uFlagsBelow); + expect(-1, r); + + DestroyWindow(hwnd); +} + START_TEST(listview) { ULONG_PTR ctx_cookie; @@ -7275,6 +7305,7 @@ START_TEST(listview) test_item_state_change(); test_selected_column(); test_LVM_GETNEXTITEMINDEX(); + test_LVM_GETNEXTITEM(); test_LVM_SETBKIMAGE(TRUE);
unload_v6_module(ctx_cookie, hCtx);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147045
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw1.c:3645: Test failed: Expected (0,0)-(640,480), got (-32000,-32000)-(-31840,-31969).