[PATCH 0/1] MR7599: COMCTL32: LVN_ENDLABELEDIT with empty text must send "" and not NULL
From: Anders Kjersem <andersdev(a)proton.me> --- dlls/comctl32/listview.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 1a0c919e962..d1d2f0ee263 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -5922,19 +5922,18 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL if (storeText) { DWORD len = isW ? GetWindowTextLengthW(infoPtr->hwndEdit) : GetWindowTextLengthA(infoPtr->hwndEdit); + ++len; /* Room for terminator (empty text must notify with "", not NULL) */ - if (len++) - { - if (!(pszText = Alloc(len * (isW ? sizeof(WCHAR) : sizeof(CHAR))))) - return FALSE; + if (!(pszText = Alloc(len * (isW ? sizeof(WCHAR) : sizeof(CHAR))))) + return FALSE; - if (isW) - GetWindowTextW(infoPtr->hwndEdit, pszText, len); - else - GetWindowTextA(infoPtr->hwndEdit, (CHAR*)pszText, len); - } + if (isW) + GetWindowTextW(infoPtr->hwndEdit, pszText, len); + else + GetWindowTextA(infoPtr->hwndEdit, (CHAR*)pszText, len); } + TRACE("(pszText=%s, isW=%d)\n", debugtext_t(pszText, isW), isW); ZeroMemory(&dispInfo, sizeof(dispInfo)); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7599
Hi, @anders. Thank you for this fix. I think it makes sense, but it needs some tests (see g_editbox_disp_info in existing tests), and some rewording for the subject line. It's still possible to get NULL text there, when text is "same". Also, previously zero-length string will cause early return and LISTVIEW_SetItemT() wasn't called. This also has to be tested. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7599#note_98112
On Mon Mar 17 15:58:58 2025 +0000, Nikolay Sivov wrote:
Hi, @anders. Thank you for this fix. I think it makes sense, but it needs some tests (see g_editbox_disp_info in existing tests), and some rewording for the subject line. It's still possible to get NULL text there, when text is "same". Also, previously zero-length string will cause early return and LISTVIEW_SetItemT() wasn't called. This also has to be tested. NULL is same text (edit aborted by the user). From MSDN "If the user cancels editing or doesn't change the text and presses Enter key, the pszText member of the LVITEM structure is NULL"
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7599#note_98113
Resubmitted with a test as !7602. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7599#note_98130
This merge request was closed by Zhiyi Zhang. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7599
participants (4)
-
Anders Kjersem -
Anders Kjersem (@anders) -
Nikolay Sivov (@nsivov) -
Zhiyi Zhang (@zhiyi)