From 23d28487c4a88e0c151061f997222a7aa3d9d91f Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 7 Jan 2025 10:24:47 +0100 Subject: [PATCH] Terminal: Fix freeze when closing terminal on newer Windows 11 Windows 11 24H2 changed the underlying implementation and the "ClosePseudoConsole" code that we copied from the Terminal application didn't work as it did before. The new Terminal releases also removes the WaitForSingleObject call. See https://github.com/microsoft/terminal/pull/17704 We cannot rely on the ConPty API since it doesn't send the "-- resizeQuirk" parameter to "conhost.exe", and the QTCREATORBUG-30007 would be resurrected. Fixes: QTCREATORBUG-32192 Change-Id: Ie21833a1eb21acd0ba21109f3dbc28595b0d94a4 Reviewed-by: Marcus Tillmanns --- src/libs/3rdparty/libptyqt/conptyprocess.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/libs/3rdparty/libptyqt/conptyprocess.cpp b/src/libs/3rdparty/libptyqt/conptyprocess.cpp index d8f0608ef16..31497d3333a 100644 --- a/src/libs/3rdparty/libptyqt/conptyprocess.cpp +++ b/src/libs/3rdparty/libptyqt/conptyprocess.cpp @@ -582,18 +582,6 @@ void _ClosePseudoConsoleMembers(_In_ PseudoConsole* pPty) // has yet to send before we hard kill it. if (_HandleIsValid(pPty->hConPtyProcess)) { - // If the conhost is already dead, then that's fine. Presumably - // it's finished flushing it's output already. - DWORD dwExit = 0; - // If GetExitCodeProcess failed, it's likely conhost is already dead - // If so, skip waiting regardless of whatever error - // GetExitCodeProcess returned. - // We'll just go straight to killing conhost. - if (GetExitCodeProcess(pPty->hConPtyProcess, &dwExit) && dwExit == STILL_ACTIVE) - { - WaitForSingleObject(pPty->hConPtyProcess, INFINITE); - } - TerminateProcess(pPty->hConPtyProcess, 0); CloseHandle(pPty->hConPtyProcess); pPty->hConPtyProcess = nullptr; @@ -754,7 +742,7 @@ public: typedef HRESULT (*CreatePseudoConsolePtr)( COORD size, // ConPty Dimensions HANDLE hInput, // ConPty Input - HANDLE hOutput, // ConPty Output + HANDLE hOutput, // ConPty Output DWORD dwFlags, // ConPty Flags HPCON* phPC); // ConPty Reference @@ -762,7 +750,7 @@ public: typedef VOID (*ClosePseudoConsolePtr)(HPCON hPC); - static WindowsContext &instance() + static WindowsContext &instance() { static WindowsContext ctx; return ctx;