Dan Bassi : comctl32/treeview: Improve item text change detection.
Alexandre Julliard
julliard at winehq.org
Fri Apr 13 15:54:51 CDT 2018
Module: wine
Branch: master
Commit: c5cb2f1c503106cca066985c79aed727168a2f07
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c5cb2f1c503106cca066985c79aed727168a2f07
Author: Dan Bassi <wine.fixes at gmail.com>
Date: Fri Apr 13 10:24:40 2018 +0300
comctl32/treeview: Improve item text change detection.
Signed-off-by: Dan Bassi <wine.fixes at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/treeview.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 65eff8b..49eec4a 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -1125,8 +1125,10 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
if (tvItem->mask & TVIF_TEXT)
{
item->textWidth = 0; /* force width recalculation */
- if (tvItem->pszText != LPSTR_TEXTCALLBACKW && tvItem->pszText != NULL) /* covers != TEXTCALLBACKA too, and undocumented: pszText of NULL also means TEXTCALLBACK */
- {
+
+ /* Covers != TEXTCALLBACKA too, and undocumented: pszText of NULL also means TEXTCALLBACK */
+ if (tvItem->pszText != LPSTR_TEXTCALLBACKW && tvItem->pszText != NULL)
+ {
int len;
LPWSTR newText;
if (isW)
@@ -1134,12 +1136,14 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
else
len = MultiByteToWideChar(CP_ACP, 0, (LPSTR)tvItem->pszText, -1, NULL, 0);
- newText = heap_realloc(item->pszText, len * sizeof(WCHAR));
+ /* Allocate new block to make pointer comparison in item_changed() work. */
+ newText = heap_alloc(len * sizeof(WCHAR));
if (newText == NULL) return FALSE;
callbackClear |= TVIF_TEXT;
+ heap_free(item->pszText);
item->pszText = newText;
item->cchTextMax = len;
if (isW)
@@ -2199,7 +2203,7 @@ TREEVIEW_SetItemT(TREEVIEW_INFO *infoPtr, const TVITEMEXW *tvItem, BOOL isW)
if (!TREEVIEW_ValidItem(infoPtr, item))
return FALSE;
- /* store the original item values */
+ /* Store the original item values. Text buffer will be freed in TREEVIEW_DoSetItemT() below. */
originalItem = *item;
if (!TREEVIEW_DoSetItemT(infoPtr, item, tvItem, isW))
More information about the wine-cvs
mailing list