[PATCH 2/2] A window can't be parent of itself.

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Sun Jan 24 12:08:50 CST 2010


This bug is exposed by the current ElsterFormular software (German
tax declaration). Tested on XP SP3. Without the patch, the main
window disappears when the software is ready.
---
 dlls/user32/tests/win.c |    2 ++
 dlls/user32/win.c       |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 2e64f32..a099aa4 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3247,6 +3247,8 @@ static void test_SetParent(void)
 
     if (!is_win9x) /* Win9x doesn't survive this test */
     {
+        ok(!SetParent(parent, parent), "SetParent should fail\n");
+        ok(!SetParent(child1, child1), "SetParent should fail\n");
         ok(!SetParent(parent, child1), "SetParent should fail\n");
         ok(!SetParent(child2, child3), "SetParent should fail\n");
         ok(SetParent(child1, parent) != 0, "SetParent should not fail\n");
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index acf70a3..a756733 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -2691,7 +2691,7 @@ HWND WINAPI SetParent( HWND hwnd, HWND parent )
     }
 
     /* Some applications try to set a child as a parent */
-    if (IsChild(hwnd, parent))
+    if (IsChild(hwnd, parent) || hwnd == parent)
     {
         SetLastError( ERROR_INVALID_PARAMETER );
         return 0;
-- 
1.6.5




More information about the wine-patches mailing list