mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-09 02:26:45 +00:00
Fix a deadlock in ShowWindow (#13309)
When we send this ShowWindow message, if we send it to it's going to need to get processed by the window message thread before returning. We're handling this message under lock. However, the first thing the conhost message thread does is lock the console. That'll deadlock us. So unlock here, first, to let the message thread deal with this message, then re-lock so later on this thread can unlock again safely. * [x] Closes #13301 * [x] Tested conhost * [x] Tested terminal
This commit is contained in:
@@ -286,7 +286,14 @@ void ConhostInternalGetSet::ShowWindow(bool showOrHide)
|
||||
{
|
||||
const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
const auto hwnd = gci.IsInVtIoMode() ? ServiceLocator::LocatePseudoWindow() : ServiceLocator::LocateConsoleWindow()->GetWindowHandle();
|
||||
::ShowWindow(hwnd, showOrHide ? SW_SHOWNOACTIVATE : SW_MINIMIZE);
|
||||
|
||||
// GH#13301 - When we send this ShowWindow message, if we send it to the
|
||||
// conhost HWND, it's going to need to get processed by the window message
|
||||
// thread before returning.
|
||||
// However, ShowWindowAsync doesn't have this problem. It'll post the
|
||||
// message to the window thread, then immediately return, so we don't have
|
||||
// to worry about deadlocking.
|
||||
::ShowWindowAsync(hwnd, showOrHide ? SW_SHOWNOACTIVATE : SW_MINIMIZE);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
||||
Reference in New Issue
Block a user