[USER32]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 2 Mar 2011 13:23:13 +0000 (13:23 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 2 Mar 2011 13:23:13 +0000 (13:23 +0000)
Patch by Thomas Faber:
When the Edit receives WM_KILLFOCUS, it will notify its parent (the ListView)
of losing focus, which in turn will send WM_CLOSE to destroy the edit control.
This will cause the edit to receive WM_DESTROY and free the EDITSTATE.
When control returns to the WM_KILLFOCUS handler, this would call
EDIT_UnlockBuffer on the now invalid EDITSTATE.
Fix this by checking the validity of the EDITSTATE before calling EDIT_UnlockBuffer.
Fixes explorer crash, when cancelling file renaming.
See issue #5895 for more details.

svn path=/trunk/; revision=50956

reactos/dll/win32/user32/controls/edit.c

index 410e486..65f3679 100644 (file)
@@ -4721,7 +4721,7 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
 
        case WM_NCDESTROY:
                result = EDIT_WM_NCDestroy(es);
 
        case WM_NCDESTROY:
                result = EDIT_WM_NCDestroy(es);
-               es = NULL;
+//             es = NULL; reactos
 #ifdef __REACTOS__
                 NtUserSetWindowFNID(hwnd, FNID_DESTROY);
 #endif
 #ifdef __REACTOS__
                 NtUserSetWindowFNID(hwnd, FNID_DESTROY);
 #endif
@@ -5009,7 +5009,9 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
                break;
        }
 
                break;
        }
 
-       if (IsWindow(hwnd) && es) EDIT_UnlockBuffer(es, FALSE);
+       /* reactos: check GetWindowLong in case es has been destroyed during processing */
+       if (IsWindow(hwnd) && es && GetWindowLongPtrW(hwnd, 0))
+               EDIT_UnlockBuffer(es, FALSE);
 
         TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
 
 
         TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);