Commit c5cb2f1c authored by Dan Bassi's avatar Dan Bassi Committed by Alexandre Julliard

comctl32/treeview: Improve item text change detection.

parent 5293cb71
...@@ -1125,7 +1125,9 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, ...@@ -1125,7 +1125,9 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
if (tvItem->mask & TVIF_TEXT) if (tvItem->mask & TVIF_TEXT)
{ {
item->textWidth = 0; /* force width recalculation */ 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; int len;
LPWSTR newText; LPWSTR newText;
...@@ -1134,12 +1136,14 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, ...@@ -1134,12 +1136,14 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
else else
len = MultiByteToWideChar(CP_ACP, 0, (LPSTR)tvItem->pszText, -1, NULL, 0); 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; if (newText == NULL) return FALSE;
callbackClear |= TVIF_TEXT; callbackClear |= TVIF_TEXT;
heap_free(item->pszText);
item->pszText = newText; item->pszText = newText;
item->cchTextMax = len; item->cchTextMax = len;
if (isW) if (isW)
...@@ -2199,7 +2203,7 @@ TREEVIEW_SetItemT(TREEVIEW_INFO *infoPtr, const TVITEMEXW *tvItem, BOOL isW) ...@@ -2199,7 +2203,7 @@ TREEVIEW_SetItemT(TREEVIEW_INFO *infoPtr, const TVITEMEXW *tvItem, BOOL isW)
if (!TREEVIEW_ValidItem(infoPtr, item)) if (!TREEVIEW_ValidItem(infoPtr, item))
return FALSE; return FALSE;
/* store the original item values */ /* Store the original item values. Text buffer will be freed in TREEVIEW_DoSetItemT() below. */
originalItem = *item; originalItem = *item;
if (!TREEVIEW_DoSetItemT(infoPtr, item, tvItem, isW)) if (!TREEVIEW_DoSetItemT(infoPtr, item, tvItem, isW))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment