Mikołaj Zalewski : comctl32: toolbar: Passing a string pointer in TB_INSERTBUTTON shouldn' t change the strings table (with test case).
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Oct 12 15:28:45 CDT 2006
Module: wine
Branch: master
Commit: c95aa8228acc57f99716ceb3845611c75f084fd3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c95aa8228acc57f99716ceb3845611c75f084fd3
Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date: Wed Oct 11 20:48:38 2006 +0200
comctl32: toolbar: Passing a string pointer in TB_INSERTBUTTON shouldn't change the strings table (with test case).
---
dlls/comctl32/tests/toolbar.c | 8 ++++++++
dlls/comctl32/toolbar.c | 32 --------------------------------
2 files changed, 8 insertions(+), 32 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 220d703..a007fa8 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -337,6 +337,7 @@ void test_add_string()
LPCSTR ret6[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q", "p", "", "q"};
LPCSTR ret7[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q", "p", "", "q", "br", "c", "d"};
HWND hToolbar = NULL;
+ TBBUTTON button;
int ret;
rebuild_toolbar(&hToolbar);
@@ -365,6 +366,13 @@ void test_add_string()
ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD7);
ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret);
CHECK_STRING_TABLE(14, ret7);
+
+ ZeroMemory(&button, sizeof(button));
+ button.iString = (UINT_PTR)"Test";
+ SendMessageA(hToolbar, TB_INSERTBUTTONA, 0, (LPARAM)&button);
+ CHECK_STRING_TABLE(14, ret7);
+ SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)&button);
+ CHECK_STRING_TABLE(14, ret7);
}
START_TEST(toolbar)
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 8531ac9..c2fd14b 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -3833,22 +3833,6 @@ TOOLBAR_InsertButtonA (HWND hwnd, WPARAM
} else if (nIndex < 0)
return FALSE;
- /* If the string passed is not an index, assume address of string
- and do our own AddString */
- if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
- LPSTR ptr;
- INT len;
-
- TRACE("string %s passed instead of index, adding string\n",
- debugstr_a((LPSTR)lpTbb->iString));
- len = strlen((LPSTR)lpTbb->iString) + 2;
- ptr = Alloc(len);
- strcpy(ptr, (LPSTR)lpTbb->iString);
- ptr[len - 1] = 0; /* ended by two '\0' */
- lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
- Free(ptr);
- }
-
TRACE("inserting button index=%d\n", nIndex);
if (nIndex > infoPtr->nNumButtons) {
nIndex = infoPtr->nNumButtons;
@@ -3922,22 +3906,6 @@ TOOLBAR_InsertButtonW (HWND hwnd, WPARAM
} else if (nIndex < 0)
return FALSE;
- /* If the string passed is not an index, assume address of string
- and do our own AddString */
- if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
- LPWSTR ptr;
- INT len;
-
- TRACE("string %s passed instead of index, adding string\n",
- debugstr_w((LPWSTR)lpTbb->iString));
- len = strlenW((LPWSTR)lpTbb->iString) + 2;
- ptr = Alloc(len*sizeof(WCHAR));
- strcpyW(ptr, (LPWSTR)lpTbb->iString);
- ptr[len - 1] = 0; /* ended by two '\0' */
- lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
- Free(ptr);
- }
-
TRACE("inserting button index=%d\n", nIndex);
if (nIndex > infoPtr->nNumButtons) {
nIndex = infoPtr->nNumButtons;
More information about the wine-cvs
mailing list