Dmitry Timoshkov : user32: Add an invalid window check to SetFocus.

Alexandre Julliard julliard at winehq.org
Thu Jan 5 15:24:42 CST 2012


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Jan  5 17:58:06 2012 +0800

user32: Add an invalid window check to SetFocus.

---

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

diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index 81169db..9fdae25 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -259,6 +259,11 @@ HWND WINAPI SetFocus( HWND hwnd )
     {
         /* Check if we can set the focus to this window */
         hwnd = WIN_GetFullHandle( hwnd );
+        if (!IsWindow( hwnd ))
+        {
+            SetLastError( ERROR_INVALID_WINDOW_HANDLE );
+            return 0;
+        }
         if (hwnd == previous) return previous;  /* nothing to do */
         for (;;)
         {
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index c14fc04..6fa4d10 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -13573,10 +13573,9 @@ static void test_SetFocus(void)
 
     SetLastError(0xdeadbeef);
     old_focus = SetFocus((HWND)0xdeadbeef);
-todo_wine
     ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
     while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
-    ok_sequence(WmEmptySeq, "SetFocus on an invalid window", TRUE);
+    ok_sequence(WmEmptySeq, "SetFocus on an invalid window", FALSE);
     ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());




More information about the wine-cvs mailing list