Skip to content

Commit 5268019

Browse files
committed
[0.4.12][EXPLORER] Mitigate CORE-15760 'system menu may close unexpectedly'
Looks like a race condition of the async part of SetForegroundWindow(). KVM https://reactos.org/testman/compare.php?ids=69065,69069 VBOX https://reactos.org/testman/compare.php?ids=69064,69068 The regression was unhidden by SVN 74972 == 19dd22d cherry-picked from 0.4.13-dev-1165-g d2976ca
1 parent 3a6cb85 commit 5268019

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

base/shell/explorer/taskswnd.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,13 @@ class CTaskSwitchWnd :
16331633

16341634
ActivateTask(TaskItem->hWnd);
16351635

1636+
/* Wait up to 2 seconds for the window to process the foreground notification. */
1637+
DWORD_PTR resultDummy;
1638+
if (!SendMessageTimeout(TaskItem->hWnd, WM_NULL, 0, 0, 0, 2000, &resultDummy))
1639+
ERR("HandleTaskItemRightClick detected the window was unresponsive for 2 seconds, or was destroyed\n");
1640+
if (GetForegroundWindow() != TaskItem->hWnd)
1641+
ERR("HandleTaskItemRightClick detected the window did not become foreground\n");
1642+
16361643
::SendMessageW(TaskItem->hWnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y));
16371644
}
16381645

0 commit comments

Comments
 (0)