Alexandre Julliard : user32: Fix the return value of EnumThreadWindows.
Alexandre Julliard
julliard at winehq.org
Fri Oct 23 10:19:05 CDT 2009
Module: wine
Branch: master
Commit: 1b27890af69f78f657ddac886b9eaecf4372cf28
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1b27890af69f78f657ddac886b9eaecf4372cf28
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Oct 23 14:46:58 2009 +0200
user32: Fix the return value of EnumThreadWindows.
---
dlls/user32/tests/win.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++
dlls/user32/win.c | 5 ++-
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 63f25bc..1c9103a 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -569,6 +569,60 @@ static void test_parent_owner(void)
DestroyWindow( owner );
}
+static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lParam)
+{
+ (*(LPINT)lParam)++;
+ if (*(LPINT)lParam > 2) return FALSE;
+ return TRUE;
+}
+static DWORD CALLBACK enum_thread( void *arg )
+{
+ INT count;
+ HWND hwnd[3];
+ BOOL ret;
+ MSG msg;
+
+ PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */
+
+ count = 0;
+ ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count );
+ ok( ret, "EnumThreadWindows should have returned TRUE\n" );
+ ok( count == 0, "count should be 0 got %d\n", count );
+
+ hwnd[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP,
+ 0, 0, 100, 100, 0, 0, 0, NULL );
+ count = 0;
+ ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count );
+ ok( ret, "EnumThreadWindows should have returned TRUE\n" );
+ if (count != 2) /* Vista gives us two windows for the price of one */
+ {
+ ok( count == 1, "count should be 1 got %d\n", count );
+ hwnd[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP,
+ 0, 0, 100, 100, 0, 0, 0, NULL );
+ }
+ else hwnd[2] = 0;
+
+ hwnd[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP,
+ 0, 0, 100, 100, 0, 0, 0, NULL );
+ count = 0;
+ ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count );
+ ok( !ret, "EnumThreadWindows should have returned FALSE\n" );
+ ok( count == 3, "count should be 1 got %d\n", count );
+
+ if (hwnd[2]) DestroyWindow(hwnd[2]);
+ DestroyWindow(hwnd[1]);
+ DestroyWindow(hwnd[0]);
+ return 0;
+}
+
+/* test EnumThreadWindows in a separate thread */
+static void test_enum_thread_windows(void)
+{
+ DWORD id;
+ HANDLE handle = CreateThread( NULL, 0, enum_thread, 0, 0, &id );
+ ok( !WaitForSingleObject( handle, 10000 ), "wait failed\n" );
+ CloseHandle( handle );
+}
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
@@ -5762,6 +5816,7 @@ START_TEST(win)
test_CreateWindow();
test_parent_owner();
test_SetParent();
+ test_enum_thread_windows();
test_mdi();
test_icons();
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 3e6dc37..d6746b0 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3151,6 +3151,7 @@ BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam )
{
HWND *list;
int i;
+ BOOL ret = TRUE;
USER_CheckNotLock();
@@ -3159,9 +3160,9 @@ BOOL WINAPI EnumThreadWindows( DWORD id, WNDENUMPROC func, LPARAM lParam )
/* Now call the callback function for every window */
for (i = 0; list[i]; i++)
- if (!func( list[i], lParam )) break;
+ if (!(ret = func( list[i], lParam ))) break;
HeapFree( GetProcessHeap(), 0, list );
- return TRUE;
+ return ret;
}
More information about the wine-cvs
mailing list