From: Zhiyi Zhang Subject: [PATCH 2/2] uxtheme: Avoid calling application dialog procedures repeatedly. Message-Id: Date: Wed, 29 Jun 2022 03:18:55 +0000 In-Reply-To: References: From: Zhiyi Zhang Application dialog procedures are called in UXTHEME_DefDlgProc(), then may be called again in USER_DefDlgProcA/W(). Lotus Approach doesn't expect this and run into infinite recursion. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52586 Signed-off-by: Zhiyi Zhang --- dlls/uxtheme/dialog.c | 21 +++++++++++++++++---- dlls/uxtheme/tests/system.c | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dlls/uxtheme/dialog.c b/dlls/uxtheme/dialog.c index 13943d753bb..a27382af784 100644 --- a/dlls/uxtheme/dialog.c +++ b/dlls/uxtheme/dialog.c @@ -131,12 +131,25 @@ LRESULT WINAPI UXTHEME_DefDlgProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, BOO dlgproc = (WNDPROC)GetWindowLongPtrW(hwnd, DWLP_DLGPROC); SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, 0); lr = LOWORD(CallWindowProcW(dlgproc, hwnd, msg, wp, lp)); - if (lr) + if (lr || !IsWindow(hwnd)) return GetWindowLongPtrW(hwnd, DWLP_MSGRESULT); brush = get_dialog_background_brush(hwnd, TRUE); if (!brush) - break; + { + /* Copied from DEFDLG_Proc() */ + brush = (HBRUSH)SendMessageW(hwnd, WM_CTLCOLORDLG, wp, (LPARAM)hwnd); + if (!brush) + brush = (HBRUSH)DefWindowProcW(hwnd, WM_CTLCOLORDLG, wp, (LPARAM)hwnd); + if (brush) + { + hdc = (HDC)wp; + GetClientRect(hwnd, &rect); + DPtoLP(hdc, (LPPOINT)&rect, 2); + FillRect(hdc, &rect, brush); + } + return TRUE; + } /* Using FillRect() to draw background could introduce a tiling effect if the destination * rectangle is larger than the pattern brush size, which is usually 10x600. This bug is @@ -157,12 +170,12 @@ LRESULT WINAPI UXTHEME_DefDlgProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, BOO { dlgproc = (WNDPROC)GetWindowLongPtrW(hwnd, DWLP_DLGPROC); lr = CallWindowProcW(dlgproc, hwnd, msg, wp, lp); - if (lr) + if (lr || !IsWindow(hwnd)) return lr; brush = get_dialog_background_brush(hwnd, FALSE); if (!brush) - break; + return DefWindowProcW(hwnd, msg, wp, lp); hdc = (HDC)wp; SetBkColor(hdc, GetSysColor(COLOR_BTNFACE)); diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index 4301a0f76f2..29fe5ec047d 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -2319,7 +2319,7 @@ static void test_EnableThemeDialogTexture(void) sprintf(buffer, "message %#x\n", message_tests[i].msg); flush_sequences(sequences, NUM_MSG_SEQUENCES); SendMessageW(dialog, message_tests[i].msg, (WPARAM)child_hdc, (LPARAM)child); - ok_sequence(sequences, PARENT_SEQ_INDEX, message_tests[i].msg_seq, buffer, TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, message_tests[i].msg_seq, buffer, FALSE); } ReleaseDC(child, child_hdc); EndDialog(dialog, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/335