From bcfffe7b08520b4029b47455e32c9d9ee50de75a Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 16 Oct 2002 19:56:06 +0000 Subject: [PATCH] Duplicate selected items list in LISTVIEW_RemoveAllSelections to prevent infinite loops. --- dlls/comctl32/listview.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 0027f2c0c7f..a8a5c3f1cc8 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -2375,7 +2375,8 @@ static LRESULT LISTVIEW_RemoveAllSelections(LISTVIEW_INFO *infoPtr, INT nSkipIte { LVITEMW lvItem; RANGE *sel; - INT i; + INT i, pos; + HDPA clone; if (infoPtr->bRemovingAllSelections) return TRUE; @@ -2386,16 +2387,17 @@ static LRESULT LISTVIEW_RemoveAllSelections(LISTVIEW_INFO *infoPtr, INT nSkipIte lvItem.state = 0; lvItem.stateMask = LVIS_SELECTED; - do + /* need to clone the DPA because callbacks can change it */ + clone = DPA_Clone(infoPtr->hdpaSelectionRanges, NULL); + for ( pos = 0; (sel = DPA_GetPtr(clone, pos)); pos++ ) { - sel = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 0); - if (!sel) continue; - if (infoPtr->hdpaSelectionRanges->nItemCount == 1 && - sel->lower == nSkipItem && sel->upper == nSkipItem) break; for(i = sel->lower; i <= sel->upper; i++) - if (i != nSkipItem) LISTVIEW_SetItemState(infoPtr, i, &lvItem); + { + if (i != nSkipItem) + LISTVIEW_SetItemState(infoPtr, i, &lvItem); + } } - while (infoPtr->hdpaSelectionRanges->nItemCount > 0); + DPA_Destroy(clone); infoPtr->bRemovingAllSelections = FALSE;