Do not send clipboard message to application under debugger.
Fix Qt Creator hang when copying a stack trace from an application showing a runtime assert. Change-Id: I874bd48643ebce1a3551644dc850cb7cf5869522 Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>bb10
parent
9a89d614f2
commit
333817b9cf
|
|
@ -178,6 +178,20 @@ void QWindowsClipboard::unregisterViewer()
|
|||
}
|
||||
}
|
||||
|
||||
static bool isProcessBeingDebugged(HWND hwnd)
|
||||
{
|
||||
DWORD pid = 0;
|
||||
if (!GetWindowThreadProcessId(hwnd, &pid) || !pid)
|
||||
return false;
|
||||
const HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
|
||||
if (!processHandle)
|
||||
return false;
|
||||
BOOL debugged = FALSE;
|
||||
CheckRemoteDebuggerPresent(processHandle, &debugged);
|
||||
CloseHandle(processHandle);
|
||||
return debugged != FALSE;
|
||||
}
|
||||
|
||||
void QWindowsClipboard::propagateClipboardMessage(UINT message, WPARAM wParam, LPARAM lParam) const
|
||||
{
|
||||
if (!m_nextClipboardViewer)
|
||||
|
|
@ -189,6 +203,12 @@ void QWindowsClipboard::propagateClipboardMessage(UINT message, WPARAM wParam, L
|
|||
qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO);
|
||||
return;
|
||||
}
|
||||
// Also refuse if the process is being debugged, specifically, if it is
|
||||
// displaying a runtime assert, which is not caught by isHungAppWindow().
|
||||
if (isProcessBeingDebugged(m_nextClipboardViewer)) {
|
||||
qWarning("%s: Cowardly refusing to send clipboard message to application under debugger...", Q_FUNC_INFO);
|
||||
return;
|
||||
}
|
||||
SendMessage(m_nextClipboardViewer, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue