[PATCH 0/1] MR6160: comctl32: Fix sorting for listview.
The listview wine bug 56140 is caused by passing the incorrect index to the LISTVIEW_SortItems callers custom compare function. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6160
From: Jacob Czekalla <jczekalla(a)codeweavers.com> --- dlls/comctl32/listview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index c82473b6205..0302e3e19a0 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -9396,7 +9396,7 @@ static BOOL LISTVIEW_SortItems(LISTVIEW_INFO *infoPtr, PFNLVCOMPARE pfnCompare, if (infoPtr->nFocusedItem >= 0) focusedItem = DPA_GetPtr(infoPtr->hdpaItems, infoPtr->nFocusedItem); - context.items = hdpaItems; + context.items = infoPtr->hdpaItems; context.compare_func = pfnCompare; context.lParam = lParamSort; if (IsEx) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6160
Would you mind adding a `Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56140` into the comment? To explain, the callback function takes two indices, which are relative to the original (unsorted) array. The indices are calculated in `LISTVIEW_CallBackCompare/Ex`, finding the position of the items in `context->items`. So if we need to pass the original array here, otherwise we get messed up indices. Right? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6160#note_77087
On Fri Jul 26 12:45:53 2024 +0000, Fabian Maurer wrote:
Would you mind adding a `Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56140` into the comment? To explain, the callback function takes two indices, which are relative to the original (unsorted) array. The indices are calculated in `LISTVIEW_CallBackCompare/Ex`, finding the position of the items in `context->items`. So if we need to pass the original array here, otherwise we get messed up indices. Right? Yes. If we pass the copied array indices, which are different because of the sorting, the caller is going to use those indices for their unsorted array which don't match.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/6160#note_77141
Could you please add some tests? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6160#note_77265
participants (4)
-
Fabian Maurer (@DarkShadow44) -
Jacob Czekalla -
Jacob Czekalla (@JacobCzekalla) -
Zhiyi Zhang (@zhiyi)