user32: A window is after a call to SetParent invisible when hwnd and newParent is equal (bug 21497)

Bernhard Übelacker bernhardu at vr-web.de
Tue Feb 2 07:23:42 CST 2010


(Resent, my first mail has not appeared on the list?)

Hello,
in SetParent the window (hwnd) get hidden by ShowWindow( hwnd, SW_HIDE ),
then a call to wineserver is done
and then the window is made visible again.

If this call to wineserver fails the window stays invisible.

This patch at least avoids this when hwnd and newParent is equal.
(If there are other cases this call could fail the window stays invisble.)

It could be observed in http://bugs.winehq.org/show_bug.cgi?id=21497

I want to ask for some comments what to change or if it could be sent to
wine-patches as it is?

Kind regards
Bernhard

---
 dlls/user32/tests/win.c |    6 ++++++
 dlls/user32/win.c       |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 6fb6ce0..82caccb 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -445,6 +445,12 @@ static void test_parent_owner(void)
     ret = SetParent( test, child );
     ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
     check_parents( test, child, child, 0, 0, hwndMain, test );
+
+    ShowWindow( test, SW_SHOW );
+    ret = SetParent( test, test );
+    ok( ret == NULL, "SetParent return value %p expected %p\n", ret, NULL );
+    ok( GetWindowLongA( test, GWL_STYLE ) & WS_VISIBLE, "window is not visible after SetParent\n" );
+    check_parents( test, child, child, 0, 0, hwndMain, test );
     DestroyWindow( test );
 
     /* owned popup */
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index acf70a3..8308ba8 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -2690,8 +2690,8 @@ HWND WINAPI SetParent( HWND hwnd, HWND parent )
         return 0;
     }
 
-    /* Some applications try to set a child as a parent */
-    if (IsChild(hwnd, parent))
+    /* Some applications try to set a child as a parent or itself */
+    if (IsChild(hwnd, parent) || hwnd == parent)
     {
         SetLastError( ERROR_INVALID_PARAMETER );
         return 0;
-- 
1.6.5



More information about the wine-devel mailing list