Francois Gouget : comctl32: TTM_ADDTOOLW must refuse to set a tooltip text to NULL.
Alexandre Julliard
julliard at winehq.org
Mon Dec 2 13:37:51 CST 2013
Module: wine
Branch: master
Commit: 542652deab875c3966424dc831e0fea010ed0f9d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=542652deab875c3966424dc831e0fea010ed0f9d
Author: Francois Gouget <fgouget at free.fr>
Date: Fri Nov 29 18:55:36 2013 +0100
comctl32: TTM_ADDTOOLW must refuse to set a tooltip text to NULL.
---
dlls/comctl32/status.c | 2 +
dlls/comctl32/tests/tooltips.c | 2 +-
dlls/comctl32/tooltips.c | 47 ++++++++++++++++++++++-----------------
dlls/comctl32/trackbar.c | 4 ++-
4 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index c4efedb..4528e24 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -700,10 +700,12 @@ STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts)
if (infoPtr->hwndToolTip) {
INT nTipCount;
TTTOOLINFOW ti;
+ WCHAR wEmpty = 0;
ZeroMemory (&ti, sizeof(TTTOOLINFOW));
ti.cbSize = sizeof(TTTOOLINFOW);
ti.hwnd = infoPtr->Self;
+ ti.lpszText = &wEmpty;
nTipCount = SendMessageW (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
if (nTipCount < infoPtr->numParts) {
diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c
index d5f97b3..63436e0 100644
--- a/dlls/comctl32/tests/tooltips.c
+++ b/dlls/comctl32/tests/tooltips.c
@@ -420,7 +420,7 @@ static void test_gettext(void)
toolinfoW.lParam = 0xdeadbeef;
GetClientRect(hwnd, &toolinfoW.rect);
r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfoW);
- todo_wine ok(!r, "Adding the tool to the tooltip failed\n");
+ ok(!r, "Adding the tool to the tooltip succeeded!\n");
if (0) /* crashes on NT4 */
{
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c
index a325bcc..f74ea65 100644
--- a/dlls/comctl32/tooltips.c
+++ b/dlls/comctl32/tooltips.c
@@ -1037,6 +1037,9 @@ TOOLTIPS_AddToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW)
infoPtr->hwndSelf, ti->hwnd, ti->uId,
(ti->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
+ if (ti->cbSize >= TTTOOLINFOW_V2_SIZE && !ti->lpszText && isW)
+ return FALSE;
+
if (infoPtr->uNumTools == 0) {
infoPtr->tools = Alloc (sizeof(TTTOOL_INFO));
toolPtr = infoPtr->tools;
@@ -1060,27 +1063,29 @@ TOOLTIPS_AddToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW)
toolPtr->rect = ti->rect;
toolPtr->hinst = ti->hinst;
- if (IS_INTRESOURCE(ti->lpszText)) {
- TRACE("add string id %x\n", LOWORD(ti->lpszText));
- toolPtr->lpszText = ti->lpszText;
- }
- else if (ti->lpszText) {
- if (TOOLTIPS_IsCallbackString(ti->lpszText, isW)) {
- TRACE("add CALLBACK!\n");
- toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
- }
- else if (isW) {
- INT len = lstrlenW (ti->lpszText);
- TRACE("add text %s!\n", debugstr_w(ti->lpszText));
- toolPtr->lpszText = Alloc ((len + 1)*sizeof(WCHAR));
- strcpyW (toolPtr->lpszText, ti->lpszText);
- }
- else {
- INT len = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ti->lpszText, -1, NULL, 0);
- TRACE("add text \"%s\"!\n", (LPSTR)ti->lpszText);
- toolPtr->lpszText = Alloc (len * sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, (LPSTR)ti->lpszText, -1, toolPtr->lpszText, len);
- }
+ if (ti->cbSize >= TTTOOLINFOW_V1_SIZE) {
+ if (IS_INTRESOURCE(ti->lpszText)) {
+ TRACE("add string id %x\n", LOWORD(ti->lpszText));
+ toolPtr->lpszText = ti->lpszText;
+ }
+ else if (ti->lpszText) {
+ if (TOOLTIPS_IsCallbackString(ti->lpszText, isW)) {
+ TRACE("add CALLBACK!\n");
+ toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
+ }
+ else if (isW) {
+ INT len = lstrlenW (ti->lpszText);
+ TRACE("add text %s!\n", debugstr_w(ti->lpszText));
+ toolPtr->lpszText = Alloc ((len + 1)*sizeof(WCHAR));
+ strcpyW (toolPtr->lpszText, ti->lpszText);
+ }
+ else {
+ INT len = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ti->lpszText, -1, NULL, 0);
+ TRACE("add text \"%s\"!\n", (LPSTR)ti->lpszText);
+ toolPtr->lpszText = Alloc (len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, (LPSTR)ti->lpszText, -1, toolPtr->lpszText, len);
+ }
+ }
}
if (ti->cbSize >= TTTOOLINFOW_V2_SIZE)
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c
index 9673771..6d092a3 100644
--- a/dlls/comctl32/trackbar.c
+++ b/dlls/comctl32/trackbar.c
@@ -1525,11 +1525,13 @@ TRACKBAR_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
hwnd, 0, 0, 0);
if (infoPtr->hwndToolTip) {
- TTTOOLINFOW ti;
+ TTTOOLINFOW ti;
+ WCHAR wEmpty = 0;
ZeroMemory (&ti, sizeof(ti));
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
ti.hwnd = hwnd;
+ ti.lpszText = &wEmpty;
SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 0, (LPARAM)&ti);
}
More information about the wine-cvs
mailing list