diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-03-17 11:23:51 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-03-17 11:23:51 (GMT) |
commit | 2ba58fc0a36a30d19e46f9c012598958f98c2e33 (patch) | |
tree | ff3c7758569ee300d6aebb62beb65509472da47d /src | |
parent | 60bec281fe0a82556c07db3f8e13587d47b8449e (diff) | |
download | Qt-2ba58fc0a36a30d19e46f9c012598958f98c2e33.zip Qt-2ba58fc0a36a30d19e46f9c012598958f98c2e33.tar.gz Qt-2ba58fc0a36a30d19e46f9c012598958f98c2e33.tar.bz2 |
Clipboard/Windows: Fix a hang when sending to non-responsive clients.
Check if clipboard viewer is responsive before sending the
contents. This prevents Qt Creator from hanging when copying
text while a debugging session with a crashed/stopped
debuggee is in progress.
Reviewed-by: Prasanth Ullattil <prasanth.ullattil@nokia.com>
Task-number: QTBUG-17465
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qclipboard_win.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/gui/kernel/qclipboard_win.cpp index 52b9663..ea41165 100644 --- a/src/gui/kernel/qclipboard_win.cpp +++ b/src/gui/kernel/qclipboard_win.cpp @@ -52,6 +52,7 @@ #include "qt_windows.h" #include "qdnd_p.h" #include <private/qwidget_p.h> +#include <private/qsystemlibrary_p.h> QT_BEGIN_NAMESPACE @@ -70,6 +71,9 @@ void QtCeFlushClipboard(); #endif +typedef BOOL (WINAPI *PtrIsHungAppWindow)(HWND); + +static PtrIsHungAppWindow ptrIsHungAppWindow = 0; class QClipboardWatcher : public QInternalMimeData { public: @@ -327,9 +331,16 @@ bool QClipboard::event(QEvent *e) d->releaseIData(); propagate = true; } - if (propagate && d->nextClipboardViewer) { - SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam); + if (ptrIsHungAppWindow == 0) { + QSystemLibrary library(QLatin1String("User32")); + ptrIsHungAppWindow = (PtrIsHungAppWindow)library.resolve("IsHungAppWindow"); + } + if (ptrIsHungAppWindow && ptrIsHungAppWindow(d->nextClipboardViewer)) { + qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO); + } else { + SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam); + } } return true; |