This was observed in ReactOS, when 'Debug Page Heap'[^1] was enabled: - Start renaming a file in a shell view - Cancel the renaming
[^1]: DPH is modeled after 'Windows Page Heap Verification'
From: Mark Jansen mark.jansen@reactos.org
--- dlls/comctl32/edit.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index 3111cda2a4b..d9831efa2ad 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -3403,12 +3403,18 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key) static LRESULT EDIT_WM_KillFocus(HTHEME theme, EDITSTATE *es) { UINT flags = RDW_INVALIDATE; + HWND hwndSelf = es->hwndSelf;
es->flags &= ~EF_FOCUSED; DestroyCaret(); if (!(es->style & ES_NOHIDESEL)) EDIT_InvalidateText(es, es->selection_start, es->selection_end); EDIT_NOTIFY_PARENT(es, EN_KILLFOCUS); + + /* Someone destroyed us in the EN_KILLFOCUS handler, so we can't use 'es' anymore */ + if (!IsWindow(hwndSelf)) + return 0; + /* Throw away left over scroll when we lose focus */ es->wheelDeltaRemainder = 0;
I'd rather we used something similar to Listview helper, instead of a macro. This helper checks for valid window on return, for every notifications.
After that the same fix has to be made for user32/edit.c.
Please check if this works for you.
[0001-comctl32-edit-Check-for-control-destruction-on-notifca.txt](/uploads/b0ec758262ac76ef3fe0677551679fcd/0001-comctl32-edit-Check-for-control-destruction-on-notifca.txt)
This patch does work for me, thanks!
I opened !1270 that applies this change to both implementations.
This merge request was closed by Nikolay Sivov.