- Don't leak memory when an app sends TTM_SETTITLE twice.
- An lParam of 0 indicates that the title should be removed.
This commit is contained in:
parent
a2c8af4205
commit
acfd725df4
|
@ -1927,16 +1927,25 @@ TOOLTIPS_SetTitleA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
||||||
LPCSTR pszTitle = (LPCSTR)lParam;
|
LPCSTR pszTitle = (LPCSTR)lParam;
|
||||||
UINT uTitleIcon = (UINT)wParam;
|
UINT_PTR uTitleIcon = (UINT_PTR)wParam;
|
||||||
UINT size;
|
UINT size;
|
||||||
|
|
||||||
TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, pszTitle, (void*)uTitleIcon);
|
TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_a(pszTitle),
|
||||||
|
(void*)uTitleIcon);
|
||||||
|
|
||||||
|
Free(infoPtr->pszTitle);
|
||||||
|
|
||||||
|
if (pszTitle)
|
||||||
|
{
|
||||||
size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0);
|
size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0);
|
||||||
infoPtr->pszTitle = Alloc(size);
|
infoPtr->pszTitle = Alloc(size);
|
||||||
if (!infoPtr->pszTitle)
|
if (!infoPtr->pszTitle)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR));
|
MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
infoPtr->pszTitle = NULL;
|
||||||
|
|
||||||
if (uTitleIcon <= TTI_ERROR)
|
if (uTitleIcon <= TTI_ERROR)
|
||||||
infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
|
infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
|
||||||
else
|
else
|
||||||
|
@ -1951,16 +1960,25 @@ TOOLTIPS_SetTitleW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
||||||
LPCWSTR pszTitle = (LPCWSTR)lParam;
|
LPCWSTR pszTitle = (LPCWSTR)lParam;
|
||||||
UINT uTitleIcon = (UINT)wParam;
|
UINT_PTR uTitleIcon = (UINT_PTR)wParam;
|
||||||
UINT size;
|
UINT size;
|
||||||
|
|
||||||
TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle), (void*)uTitleIcon);
|
TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle),
|
||||||
|
(void*)uTitleIcon);
|
||||||
|
|
||||||
|
Free(infoPtr->pszTitle);
|
||||||
|
|
||||||
|
if (pszTitle)
|
||||||
|
{
|
||||||
size = (strlenW(pszTitle)+1)*sizeof(WCHAR);
|
size = (strlenW(pszTitle)+1)*sizeof(WCHAR);
|
||||||
infoPtr->pszTitle = Alloc(size);
|
infoPtr->pszTitle = Alloc(size);
|
||||||
if (!infoPtr->pszTitle)
|
if (!infoPtr->pszTitle)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
memcpy(infoPtr->pszTitle, pszTitle, size);
|
memcpy(infoPtr->pszTitle, pszTitle, size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
infoPtr->pszTitle = NULL;
|
||||||
|
|
||||||
if (uTitleIcon <= TTI_ERROR)
|
if (uTitleIcon <= TTI_ERROR)
|
||||||
infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
|
infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue