comctl32: Treeview: Fix crash when deleting the first visible item 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:
parent
3e02882508
commit
4c799937f6
|
@ -1878,8 +1878,13 @@ static void test_delete_items(void)
|
|||
{
|
||||
const struct message *msg;
|
||||
HWND hTree;
|
||||
HTREEITEM hItem1, hItem2;
|
||||
TVINSERTSTRUCTA ins;
|
||||
INT ret;
|
||||
|
||||
static CHAR item1[] = "Item 1";
|
||||
static CHAR item2[] = "Item 2";
|
||||
|
||||
hTree = create_treeview_control(0);
|
||||
fill_tree(hTree);
|
||||
|
||||
|
@ -1901,6 +1906,34 @@ static void test_delete_items(void)
|
|||
ok(ret == 0, "got %d\n", ret);
|
||||
|
||||
DestroyWindow(hTree);
|
||||
|
||||
/* Regression test for a crash when deleting the first visible item while bRedraw == false. */
|
||||
hTree = create_treeview_control(0);
|
||||
|
||||
ins.hParent = TVI_ROOT;
|
||||
ins.hInsertAfter = TVI_ROOT;
|
||||
U(ins).item.mask = TVIF_TEXT;
|
||||
U(ins).item.pszText = item1;
|
||||
hItem1 = TreeView_InsertItemA(hTree, &ins);
|
||||
ok(hItem1 != NULL, "InsertItem failed\n");
|
||||
|
||||
ins.hParent = TVI_ROOT;
|
||||
ins.hInsertAfter = hItem1;
|
||||
U(ins).item.mask = TVIF_TEXT;
|
||||
U(ins).item.pszText = item2;
|
||||
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);
|
||||
|
||||
ret = SendMessageA(hTree, WM_SETREDRAW, TRUE, 0);
|
||||
ok(ret == 0, "got %d\n", ret);
|
||||
|
||||
DestroyWindow(hTree);
|
||||
}
|
||||
|
||||
static void test_cchildren(void)
|
||||
|
|
|
@ -1580,11 +1580,13 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM item)
|
|||
|
||||
TREEVIEW_VerifyTree(infoPtr);
|
||||
|
||||
if (visible)
|
||||
TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
|
||||
|
||||
if (!infoPtr->bRedraw) return TRUE;
|
||||
|
||||
if (visible)
|
||||
{
|
||||
TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
|
||||
TREEVIEW_RecalculateVisibleOrder(infoPtr, prev);
|
||||
TREEVIEW_UpdateScrollBars(infoPtr);
|
||||
TREEVIEW_Invalidate(infoPtr, NULL);
|
||||
|
|
Loading…
Reference in New Issue