From a2c2a83f8e5dcb07588ace4931945028b5a3f64a Mon Sep 17 00:00:00 2001 From: James Hatheway Date: Thu, 15 Feb 2001 21:24:43 +0000 Subject: [PATCH] Send LVN_DELETEITEM notification first, to avoid crashes if the app requests LVIF_PARAM with LISTVIEW_GetItem() during its LVN_DELETEITEM message handler. --- dlls/comctl32/listview.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index b6aca9166ff..92e5cad766b 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -3930,6 +3930,17 @@ static LRESULT LISTVIEW_DeleteItem(HWND hwnd, INT nItem) LVITEMA item; TRACE("(hwnd=%x,nItem=%d)\n", hwnd, nItem); + + + /* First, send LVN_DELETEITEM notification. */ + memset(&nmlv, 0, sizeof (NMLISTVIEW)); + nmlv.hdr.hwndFrom = hwnd; + nmlv.hdr.idFrom = lCtrlId; + nmlv.hdr.code = LVN_DELETEITEM; + nmlv.iItem = nItem; + SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId, + (LPARAM)&nmlv); + /* remove it from the selection range */ ZeroMemory(&item,sizeof(LVITEMA)); @@ -3973,15 +3984,6 @@ static LRESULT LISTVIEW_DeleteItem(HWND hwnd, INT nItem) lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); if (lpItem != NULL) { - /* send LVN_DELETEITEM notification */ - nmlv.hdr.hwndFrom = hwnd; - nmlv.hdr.idFrom = lCtrlId; - nmlv.hdr.code = LVN_DELETEITEM; - nmlv.iItem = nItem; - nmlv.lParam = lpItem->lParam; - SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId, - (LPARAM)&nmlv); - /* free item string */ if ((lpItem->pszText != NULL) && (lpItem->pszText != LPSTR_TEXTCALLBACKA))