summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsclipboard.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-02-26 14:31:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-17 22:14:19 +0200
commit333817b9cf1304cca7c1dbd45880115cd128f60e (patch)
treef1e2a5a7a5ff2160bf4ade70088632804ab972b8 /src/plugins/platforms/windows/qwindowsclipboard.cpp
parent9a89d614f26262fcb6895d1dab93519d732ba011 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsclipboard.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp
index b66a16ae58..cf6cb199c7 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -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);
}