Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tooltips.c | 48 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 30 deletions(-)
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index b1e8f5147a..163821aa08 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -1140,6 +1140,16 @@ static void TOOLTIPS_ResetSubclass (const TTTOOL_INFO *toolPtr) TOOLTIPS_SubclassProc, 1, 0); }
+static void TOOLTIPS_FreeToolText(TTTOOL_INFO *toolPtr) +{ + if (toolPtr->lpszText) + { + if (!IS_INTRESOURCE(toolPtr->lpszText) && toolPtr->lpszText != LPSTR_TEXTCALLBACKW) + Free(toolPtr->lpszText); + toolPtr->lpszText = NULL; + } +} + static LRESULT TOOLTIPS_DelToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) { @@ -1163,14 +1173,8 @@ TOOLTIPS_DelToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) /* make sure the tooltip has disappeared before deleting it */ TOOLTIPS_Hide(infoPtr);
- /* delete text string */ toolPtr = &infoPtr->tools[nTool]; - if (toolPtr->lpszText) { - if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) && - !IS_INTRESOURCE(toolPtr->lpszText) ) - Free (toolPtr->lpszText); - } - + TOOLTIPS_FreeToolText (toolPtr); TOOLTIPS_ResetSubclass (toolPtr);
/* delete tool from tool list */ @@ -1635,7 +1639,6 @@ TOOLTIPS_SetTitleT (TOOLTIPS_INFO *infoPtr, UINT_PTR uTitleIcon, LPCWSTR pszTitl return TRUE; }
- static LRESULT TOOLTIPS_SetToolInfoT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) { @@ -1660,12 +1663,7 @@ TOOLTIPS_SetToolInfoT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) toolPtr->rect = ti->rect; toolPtr->hinst = ti->hinst;
- if ( (toolPtr->lpszText) && - !IS_INTRESOURCE(toolPtr->lpszText) ) { - if( toolPtr->lpszText != LPSTR_TEXTCALLBACKW) - Free (toolPtr->lpszText); - toolPtr->lpszText = NULL; - } + TOOLTIPS_FreeToolText (toolPtr);
if (IS_INTRESOURCE(ti->lpszText)) { TRACE("set string id %x\n", LOWORD(ti->lpszText)); @@ -1788,6 +1786,8 @@ TOOLTIPS_UpdateTipTextT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW /* copy tool text */ toolPtr->hinst = ti->hinst;
+ TOOLTIPS_FreeToolText(toolPtr); + if (IS_INTRESOURCE(ti->lpszText)){ toolPtr->lpszText = ti->lpszText; } @@ -1795,12 +1795,6 @@ TOOLTIPS_UpdateTipTextT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW if (ti->lpszText == LPSTR_TEXTCALLBACKW) toolPtr->lpszText = LPSTR_TEXTCALLBACKW; else { - if ( (toolPtr->lpszText) && - !IS_INTRESOURCE(toolPtr->lpszText) ) { - if( toolPtr->lpszText != LPSTR_TEXTCALLBACKW) - Free (toolPtr->lpszText); - toolPtr->lpszText = NULL; - } if (ti->lpszText) { if (isW) { INT len = lstrlenW (ti->lpszText); @@ -1867,17 +1861,11 @@ TOOLTIPS_Destroy (TOOLTIPS_INFO *infoPtr)
/* free tools */ if (infoPtr->tools) { - for (i = 0; i < infoPtr->uNumTools; i++) { - toolPtr = &infoPtr->tools[i]; - if (toolPtr->lpszText) { - if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) && - !IS_INTRESOURCE(toolPtr->lpszText) ) - { - Free (toolPtr->lpszText); - toolPtr->lpszText = NULL; - } - } + for (i = 0; i < infoPtr->uNumTools; i++) + { + toolPtr = &infoPtr->tools[i];
+ TOOLTIPS_FreeToolText (toolPtr); TOOLTIPS_ResetSubclass (toolPtr); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tooltips.c | 83 +++++++++++++++------------------------- 1 file changed, 31 insertions(+), 52 deletions(-)
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 163821aa08..4b2298bf40 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -1150,6 +1150,35 @@ static void TOOLTIPS_FreeToolText(TTTOOL_INFO *toolPtr) } }
+static void TOOLTIPS_SetToolText(TTTOOL_INFO *toolPtr, WCHAR *text, BOOL is_unicode) +{ + int len; + + TOOLTIPS_FreeToolText (toolPtr); + + if (IS_INTRESOURCE(text)) + toolPtr->lpszText = text; + else if (text == LPSTR_TEXTCALLBACKW) + toolPtr->lpszText = LPSTR_TEXTCALLBACKW; + else if (text) + { + if (is_unicode) + { + len = lstrlenW(text); + toolPtr->lpszText = Alloc ((len + 1) * sizeof(WCHAR)); + if (toolPtr->lpszText) + strcpyW (toolPtr->lpszText, text); + } + else + { + len = MultiByteToWideChar(CP_ACP, 0, (char *)text, -1, NULL, 0); + toolPtr->lpszText = Alloc (len * sizeof(WCHAR)); + if (toolPtr->lpszText) + MultiByteToWideChar(CP_ACP, 0, (char *)text, -1, toolPtr->lpszText, len); + } + } +} + static LRESULT TOOLTIPS_DelToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) { @@ -1663,32 +1692,7 @@ TOOLTIPS_SetToolInfoT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) toolPtr->rect = ti->rect; toolPtr->hinst = ti->hinst;
- TOOLTIPS_FreeToolText (toolPtr); - - if (IS_INTRESOURCE(ti->lpszText)) { - TRACE("set string id %x\n", LOWORD(ti->lpszText)); - toolPtr->lpszText = ti->lpszText; - } - else { - if (ti->lpszText == LPSTR_TEXTCALLBACKW) - toolPtr->lpszText = LPSTR_TEXTCALLBACKW; - else { - if (ti->lpszText) { - if (isW) { - INT len = lstrlenW (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); - toolPtr->lpszText = Alloc (len * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, (LPSTR)ti->lpszText, -1, - toolPtr->lpszText, len); - } - } - } - } + TOOLTIPS_SetToolText (toolPtr, ti->lpszText, isW);
if (ti->cbSize >= TTTOOLINFOW_V2_SIZE) toolPtr->lParam = ti->lParam; @@ -1783,34 +1787,9 @@ TOOLTIPS_UpdateTipTextT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW
toolPtr = &infoPtr->tools[nTool];
- /* copy tool text */ toolPtr->hinst = ti->hinst;
- TOOLTIPS_FreeToolText(toolPtr); - - if (IS_INTRESOURCE(ti->lpszText)){ - toolPtr->lpszText = ti->lpszText; - } - else if (ti->lpszText) { - if (ti->lpszText == LPSTR_TEXTCALLBACKW) - toolPtr->lpszText = LPSTR_TEXTCALLBACKW; - else { - if (ti->lpszText) { - if (isW) { - INT len = lstrlenW (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); - toolPtr->lpszText = Alloc (len * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, (LPSTR)ti->lpszText, -1, - toolPtr->lpszText, len); - } - } - } - } + TOOLTIPS_SetToolText(toolPtr, ti->lpszText, isW);
if(infoPtr->nCurrentTool == -1) return 0; /* force repaint */
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tooltips.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 4b2298bf40..ce2bb8ba24 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -1838,19 +1838,16 @@ TOOLTIPS_Destroy (TOOLTIPS_INFO *infoPtr) TTTOOL_INFO *toolPtr; UINT i;
- /* free tools */ - if (infoPtr->tools) { - for (i = 0; i < infoPtr->uNumTools; i++) - { - toolPtr = &infoPtr->tools[i]; - - TOOLTIPS_FreeToolText (toolPtr); - TOOLTIPS_ResetSubclass (toolPtr); - } + for (i = 0; i < infoPtr->uNumTools; i++) + { + toolPtr = &infoPtr->tools[i];
- Free (infoPtr->tools); + TOOLTIPS_FreeToolText (toolPtr); + TOOLTIPS_ResetSubclass (toolPtr); }
+ Free (infoPtr->tools); + /* free title string */ Free (infoPtr->pszTitle); /* free title icon if not a standard one */