Commit af4a757a authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

comctl32: Prevent invalid focus change notifications from LVS_OWNERDATA lists.

parent 3f2055b1
......@@ -8808,6 +8808,7 @@ static BOOL LISTVIEW_SetItemCount(LISTVIEW_INFO *infoPtr, INT nItems, DWORD dwFl
if (infoPtr->dwStyle & LVS_OWNERDATA)
{
INT nOldCount = infoPtr->nItemCount;
infoPtr->nItemCount = nItems;
if (nItems < nOldCount)
{
......@@ -8820,7 +8821,6 @@ static BOOL LISTVIEW_SetItemCount(LISTVIEW_INFO *infoPtr, INT nItems, DWORD dwFl
}
}
infoPtr->nItemCount = nItems;
LISTVIEW_UpdateScroll(infoPtr);
/* the flags are valid only in ownerdata report and list modes */
......
......@@ -3418,6 +3418,28 @@ static void test_ownerdata(void)
style = GetWindowLongPtrA(hwnd, GWL_STYLE);
ok(style & LVS_SORTDESCENDING, "Expected LVS_SORTDESCENDING to be set\n");
DestroyWindow(hwnd);
/* The focused item is updated after the invalidation */
hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
ok(hwnd != NULL, "failed to create a listview window\n");
res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 3, 0);
expect(TRUE, res);
memset(&item, 0, sizeof(item));
item.stateMask = LVIS_FOCUSED;
item.state = LVIS_FOCUSED;
res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
expect(TRUE, res);
flush_sequences(sequences, NUM_MSG_SEQUENCES);
res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 0, 0);
expect(TRUE, res);
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
"ownerdata setitemcount", FALSE);
res = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
expect(-1, res);
DestroyWindow(hwnd);
}
static void test_norecompute(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment