comctl32/button: Delay calling get_button_text until it is needed to prevent a leak.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2019-03-25 15:31:53 +02:00 committed by Alexandre Julliard
parent 0004deba43
commit 715065feb3
1 changed files with 6 additions and 7 deletions

View File

@ -2326,10 +2326,10 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
RECT bgRect, textRect;
HFONT font = infoPtr->font;
HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL;
WCHAR *text = get_button_text(infoPtr);
NMCUSTOMDRAW nmcd;
LRESULT cdrf;
HWND parent;
WCHAR *text;
GetClientRect(infoPtr->hwnd, &bgRect);
GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect);
@ -2357,10 +2357,9 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
if (text)
if (!(cdrf & CDRF_DOERASE) && (text = get_button_text(infoPtr)))
{
if (!(cdrf & CDRF_DOERASE))
DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect);
DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect);
heap_free(text);
}
@ -2398,11 +2397,11 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
DWORD dwStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
UINT btn_type = get_button_type( dwStyle );
int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX;
WCHAR *text = get_button_text(infoPtr);
NMCUSTOMDRAW nmcd;
LRESULT cdrf;
LOGFONTW lf;
HWND parent;
WCHAR *text;
BOOL created_font = FALSE;
HRESULT hr = GetThemeFont(theme, hDC, part, state, TMT_FONT, &lf);
@ -2456,6 +2455,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
text = get_button_text(infoPtr);
if (!(cdrf & CDRF_DOERASE) && text)
DrawThemeText(theme, hDC, part, state, text, lstrlenW(text), dtFlags, 0, &textRect);
@ -2464,11 +2464,10 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
nmcd.dwDrawStage = CDDS_POSTPAINT;
SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
}
if (cdrf & CDRF_SKIPPOSTPAINT) goto cleanup;
if (text)
{
if (focused)
if (!(cdrf & CDRF_SKIPPOSTPAINT) && focused)
{
RECT focusRect;