Re: comctl32: treeview: Fix crash when deleting the first visible item while bRedraw == false
On 01/30/2016 12:11 AM, Joachim Priesner wrote:
When bRedraw == false, TREEVIEW_DeleteItem returned early, leaving firstVisible == NULL. This led to a crash when bRedraw was set to true again.
Signed-off-by: Joachim Priesner <joachim.priesner(a)web.de> --- dlls/comctl32/tests/treeview.c | 38 ++++++++++++++++++++++++++++++++++++++ dlls/comctl32/treeview.c | 4 +++- 2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 92504c1..34d0674 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -1903,6 +1903,43 @@ static void test_delete_items(void) DestroyWindow(hTree); }
+static void test_delete_first_visible_setredraw_false(void) Please append new tests to test_delete_items(), after a comment line describing what's being tested.
+{ + HWND hTree; + INT ret; + TVINSERTSTRUCTA ins; + HTREEITEM hItem1; + + static CHAR item1[] = "Item 1"; + static CHAR item2[] = "Item 2"; + + 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); Just to make sure add a test for hItem != NULL. + + ins.hParent = TVI_ROOT; + ins.hInsertAfter = hItem1; + U(ins).item.mask = TVIF_TEXT; + U(ins).item.pszText = item2; + (void*) TreeView_InsertItemA(hTree, &ins); /* return value unused */ + Same here, it'll also make a value used. + ret = SendMessageA(hTree, WM_SETREDRAW, 0, 0); + ok(ret == 0, "got %d\n", ret); + + ret = SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hItem1); + ok(ret == TRUE, "got %d\n", ret); + + /* this used to crash, test that it does not any more */ + ret = SendMessageA(hTree, WM_SETREDRAW, 1, 0); + ok(ret == 0, "got %d\n", ret); + For WM_SETREDRAW wParam please use TRUE/FALSE instead.
Otherwise looks good, thanks for fixing this.
participants (1)
-
Nikolay Sivov