Module: wine Branch: master Commit: d24095a7d1156928ab15844a54438e1de966d9f4 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d24095a7d1156928ab15844a54...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Apr 9 16:50:59 2014 +0400
comctl32: Fix LVN_DELETEALLITEMS notification for LVS_OWNERDATA case.
---
dlls/comctl32/listview.c | 17 ++++++++++------- dlls/comctl32/tests/listview.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index c5b5670..fa9895d 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -5383,9 +5383,8 @@ static HIMAGELIST LISTVIEW_CreateDragImage(LISTVIEW_INFO *infoPtr, INT iItem, LP */ static BOOL LISTVIEW_DeleteAllItems(LISTVIEW_INFO *infoPtr, BOOL destroy) { - NMLISTVIEW nmlv; HDPA hdpaSubItems = NULL; - BOOL bSuppress; + BOOL suppress = FALSE; ITEMHDR *hdrItem; ITEM_INFO *lpItem; ITEM_ID *lpID; @@ -5400,11 +5399,15 @@ static BOOL LISTVIEW_DeleteAllItems(LISTVIEW_INFO *infoPtr, BOOL destroy) SetRectEmpty(&infoPtr->rcFocus); /* But we are supposed to leave nHotItem as is! */
- /* send LVN_DELETEALLITEMS notification */ - ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); - nmlv.iItem = -1; - bSuppress = notify_listview(infoPtr, LVN_DELETEALLITEMS, &nmlv); + if (!(infoPtr->dwStyle & LVS_OWNERDATA) || !destroy) + { + NMLISTVIEW nmlv; + + memset(&nmlv, 0, sizeof(NMLISTVIEW)); + nmlv.iItem = -1; + suppress = notify_listview(infoPtr, LVN_DELETEALLITEMS, &nmlv); + }
for (i = infoPtr->nItemCount - 1; i >= 0; i--) { @@ -5412,7 +5415,7 @@ static BOOL LISTVIEW_DeleteAllItems(LISTVIEW_INFO *infoPtr, BOOL destroy) { /* send LVN_DELETEITEM notification, if not suppressed and if it is not a virtual listview */ - if (!bSuppress) notify_deleteitem(infoPtr, i); + if (!suppress) notify_deleteitem(infoPtr, i); hdpaSubItems = DPA_GetPtr(infoPtr->hdpaItems, i); lpItem = DPA_GetPtr(hdpaSubItems, 0); /* free id struct */ diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index f5d0a01..9310f56 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -330,6 +330,23 @@ static const struct message listview_destroy[] = { { 0 } };
+static const struct message listview_ownerdata_destroy[] = { + { 0x0090, sent|optional }, /* Vista */ + { WM_PARENTNOTIFY, sent }, + { WM_SHOWWINDOW, sent }, + { WM_WINDOWPOSCHANGING, sent }, + { WM_WINDOWPOSCHANGED, sent|optional }, + { WM_DESTROY, sent }, + { WM_NCDESTROY, sent }, + { 0 } +}; + +static const struct message listview_ownerdata_deleteall[] = { + { LVM_DELETEALLITEMS, sent }, + { WM_NOTIFY, sent|id, 0, 0, LVN_DELETEALLITEMS }, + { 0 } +}; + static const struct message listview_header_changed_seq[] = { { LVM_SETCOLUMNA, sent }, { WM_NOTIFY, sent|id|defwinproc, 0, 0, LISTVIEW_ID }, @@ -5059,6 +5076,7 @@ static void test_hover(void) static void test_destroynotify(void) { HWND hwnd; + BOOL ret;
hwnd = create_listview_control(LVS_REPORT); ok(hwnd != NULL, "failed to create listview window\n"); @@ -5066,6 +5084,23 @@ static void test_destroynotify(void) flush_sequences(sequences, NUM_MSG_SEQUENCES); DestroyWindow(hwnd); ok_sequence(sequences, COMBINED_SEQ_INDEX, listview_destroy, "check destroy order", FALSE); + + /* same for ownerdata list */ + hwnd = create_listview_control(LVS_REPORT|LVS_OWNERDATA); + ok(hwnd != NULL, "failed to create listview window\n"); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + DestroyWindow(hwnd); + ok_sequence(sequences, COMBINED_SEQ_INDEX, listview_ownerdata_destroy, "check destroy order, ownerdata", FALSE); + + hwnd = create_listview_control(LVS_REPORT|LVS_OWNERDATA); + ok(hwnd != NULL, "failed to create listview window\n"); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + ret = SendMessageA(hwnd, LVM_DELETEALLITEMS, 0, 0); + ok(ret == TRUE, "got %d\n", ret); + ok_sequence(sequences, COMBINED_SEQ_INDEX, listview_ownerdata_deleteall, "deleteall ownerdata", FALSE); + DestroyWindow(hwnd); }
static void test_header_notification(void)