From 71a4ac73e29a5fe05d73bb4ddfba579be500a195 Mon Sep 17 00:00:00 2001 From: Joachim Priesner Date: Sun, 14 Feb 2016 21:58:14 +0100 Subject: [PATCH] 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 Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/tests/treeview.c | 6 +++--- dlls/comctl32/treeview.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index bd030d6781c..7e6c73154d0 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -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); diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index 5938b29ebcf..ae174138a97 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -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)