comctl32: Treeview: Set visible = TRUE when deleting first visible item.

This fixes a crash when deleting the first visible item if it has
visibleOrder < 0 and thus the ISVISIBLE macro returns false
(this happens when both insertion and deletion happened while
bRedraw == false).

Signed-off-by: Joachim Priesner <joachim.priesner@web.de>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Joachim Priesner 2016-02-14 21:58:14 +01:00 committed by Alexandre Julliard
parent 9ac1744b80
commit 71a4ac73e2
2 changed files with 4 additions and 3 deletions

View file

@ -1910,6 +1910,9 @@ static void test_delete_items(void)
/* Regression test for a crash when deleting the first visible item while bRedraw == false. */
hTree = create_treeview_control(0);
ret = SendMessageA(hTree, WM_SETREDRAW, FALSE, 0);
ok(ret == 0, "got %d\n", ret);
ins.hParent = TVI_ROOT;
ins.hInsertAfter = TVI_ROOT;
U(ins).item.mask = TVIF_TEXT;
@ -1924,9 +1927,6 @@ static void test_delete_items(void)
hItem2 = TreeView_InsertItemA(hTree, &ins);
ok(hItem2 != NULL, "InsertItem failed\n");
ret = SendMessageA(hTree, WM_SETREDRAW, FALSE, 0);
ok(ret == 0, "got %d\n", ret);
ret = SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hItem1);
ok(ret == TRUE, "got %d\n", ret);

View file

@ -1545,6 +1545,7 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM item)
if (infoPtr->firstVisible == item)
{
visible = TRUE;
if (item->nextSibling)
newFirstVisible = item->nextSibling;
else if (item->prevSibling)