[PATCH] comctl32/treeview: Improve item text change detection
Nikolay Sivov
nsivov at codeweavers.com
Fri Apr 13 02:24:40 CDT 2018
From: Dan Bassi <wine.fixes at gmail.com>
Signed-off-by: Dan Bassi <wine.fixes at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 65eff8b40b..49eec4a4dc 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))
--
2.17.0
More information about the wine-devel
mailing list