=?UTF-8?Q?Gabriel=20Iv=C4=83ncescu=20?=: comctl32/button: Delay calling get_button_text until it is needed to prevent a leak.
Alexandre Julliard
julliard at winehq.org
Fri Apr 5 16:04:59 CDT 2019
Module: wine
Branch: master
Commit: 715065feb3915d37555e02f79d586f26adda1152
URL: https://source.winehq.org/git/wine.git/?a=commit;h=715065feb3915d37555e02f79d586f26adda1152
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Mon Mar 25 15:31:53 2019 +0200
comctl32/button: Delay calling get_button_text until it is needed to prevent a leak.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/button.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index e974f86..f282abf 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -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;
More information about the wine-cvs
mailing list