From: Huw Campbell <huw.campbell@gmail.com> --- dlls/comctl32/listview.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 03b940eaee1..fd9aef52b87 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -554,7 +554,7 @@ static inline int textcmpWT(LPCWSTR aw, LPCWSTR bt, BOOL isW) /******** PUColumn ownership function *************************************/ -/* Similar to Text entries, the list view owns puColumn data arrays. */ +/* The list view owns puColumn data arrays. */ /* Helper function to do the allocation */ static inline UINT* puColumnsDup(UINT cColumns, UINT* puColumns) @@ -568,8 +568,8 @@ static inline UINT* puColumnsDup(UINT cColumns, UINT* puColumns) * Dest is a pointer to a managed puColumns we are copying an owned copy to. * Src is an existing puColumns passed from the user. * - * If cColumns is I_COLUMNCALLBACK, it won't be in the range and we won't - * try to copy the source data. + * If cColumns is I_COLUMNSCALLBACK, it won't be in the range and we won't + * try to copy from the pointer. */ static inline void puColumnsSetPtr(UINT **dest, UINT* src, UINT cColumns) { @@ -577,9 +577,20 @@ static inline void puColumnsSetPtr(UINT **dest, UINT* src, UINT cColumns) if (src && cColumns > 0 && cColumns < 20) *dest = puColumnsDup(cColumns, src); else - *dest = NULL; + *dest = NULL; } +/* + * Compare two puColumn entries for equality when their cColumns entries + * have the same value. + */ +static inline INT puColumnsCmp(PUINT at, PUINT bt, UINT cColumns) +{ + if (!cColumns || cColumns == I_COLUMNSCALLBACK) return 0; + if (!at) return bt ? -1 : 0; + if (!bt) return 1; + return memcmp(at, bt, sizeof(UINT) * cColumns); +} /******** Debugging functions *****************************************/ @@ -4384,7 +4395,9 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL if ((lpLVItem->mask & LVIF_TEXT) && textcmpWT(lpItem->hdr.pszText, lpLVItem->pszText, isW)) uChanged |= LVIF_TEXT; - if (lpLVItem->mask & LVIF_COLUMNS) + if (lpLVItem->mask & LVIF_COLUMNS && ( + lpItem->cColumns != lpLVItem->cColumns || puColumnsCmp(lpItem->puColumns, lpLVItem->puColumns, lpItem->cColumns)) + ) uChanged |= LVIF_COLUMNS; TRACE("change mask=0x%x\n", uChanged); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10191