Nikolay Sivov : user32/button: Do not select old font back after painting.

Alexandre Julliard julliard at winehq.org
Thu Mar 1 13:34:44 CST 2018


Module: wine
Branch: master
Commit: b7a08c92811c0a6c10b65b8b317e7f2d178e5bf1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b7a08c92811c0a6c10b65b8b317e7f2d178e5bf1

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Mar  1 14:17:31 2018 +0300

user32/button: Do not select old font back after painting.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/button.c    | 5 ++---
 dlls/user32/tests/msg.c | 6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index 52e718f..0f56e4e 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -1096,7 +1096,7 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
     DRAWITEMSTRUCT dis;
     LONG_PTR id = GetWindowLongPtrW( hwnd, GWLP_ID );
     HWND parent;
-    HFONT hFont, hPrevFont = 0;
+    HFONT hFont;
     HRGN hrgn;
 
     dis.CtlType    = ODT_BUTTON;
@@ -1111,7 +1111,7 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
     dis.itemData   = 0;
     GetClientRect( hwnd, &dis.rcItem );
 
-    if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
+    if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
     parent = GetParent(hwnd);
     if (!parent) parent = hwnd;
     SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
@@ -1119,7 +1119,6 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
     hrgn = set_control_clipping( hDC, &dis.rcItem );
 
     SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
-    if (hPrevFont) SelectObject(hDC, hPrevFont);
     SelectClipRgn( hDC, hrgn );
     if (hrgn) DeleteObject( hrgn );
 }
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 1d569a3..36d1e33 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -6466,15 +6466,13 @@ static void test_button_messages(void)
         prevfont = SelectObject(hdc, hfont2);
         ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n");
         SendMessageA(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, 0);
-    todo_wine
-        ok(GetStockObject(SYSTEM_FONT) == GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i);
+        ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i);
         SelectObject(hdc, prevfont);
 
         prevfont = SelectObject(hdc, hfont2);
         ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n");
         SendMessageA(hwnd, WM_PAINT, (WPARAM)hdc, 0);
-    todo_wine
-        ok(GetStockObject(SYSTEM_FONT) == GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PAINT\n", i);
+        ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PAINT\n", i);
         SelectObject(hdc, prevfont);
 
         DeleteDC(hdc);




More information about the wine-cvs mailing list