Remove hook handling code from QEventDispatcherWin32
Since commit 6a7cea64
qt_GetMessageHook is effectively a no-op, and
we can remove the complete hook handling code.
Change-Id: I90383c0c09c2b0f1d715872de5f9519a879d9bae
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
6df8a30333
commit
d5f65d8814
@ -100,7 +100,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
|
||||
|
||||
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
|
||||
: threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0),
|
||||
getMessageHook(0), wakeUps(0), activateNotifiersPosted(false),
|
||||
wakeUps(0), activateNotifiersPosted(false),
|
||||
winEventNotifierActivatedEvent(NULL)
|
||||
{
|
||||
}
|
||||
@ -269,14 +269,6 @@ static inline UINT inputTimerMask()
|
||||
return result;
|
||||
}
|
||||
|
||||
LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
|
||||
{
|
||||
QEventDispatcherWin32 *q = qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance());
|
||||
Q_ASSERT(q != 0);
|
||||
|
||||
return q->d_func()->getMessageHook ? CallNextHookEx(0, code, wp, lp) : 0;
|
||||
}
|
||||
|
||||
// Provide class name and atom for the message window used by
|
||||
// QEventDispatcherWin32Private via Q_GLOBAL_STATIC shared between threads.
|
||||
struct QWindowsMessageWindowClassContext
|
||||
@ -455,38 +447,11 @@ void QEventDispatcherWin32::createInternalHwnd()
|
||||
return;
|
||||
d->internalHwnd = qt_create_internal_window(this);
|
||||
|
||||
installMessageHook();
|
||||
|
||||
// start all normal timers
|
||||
for (int i = 0; i < d->timerVec.count(); ++i)
|
||||
d->registerTimer(d->timerVec.at(i));
|
||||
}
|
||||
|
||||
void QEventDispatcherWin32::installMessageHook()
|
||||
{
|
||||
Q_D(QEventDispatcherWin32);
|
||||
|
||||
if (d->getMessageHook)
|
||||
return;
|
||||
|
||||
// setup GetMessage hook needed to drive our posted events
|
||||
d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
|
||||
if (Q_UNLIKELY(!d->getMessageHook)) {
|
||||
int errorCode = GetLastError();
|
||||
qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %ls",
|
||||
errorCode, qUtf16Printable(qt_error_string(errorCode)));
|
||||
}
|
||||
}
|
||||
|
||||
void QEventDispatcherWin32::uninstallMessageHook()
|
||||
{
|
||||
Q_D(QEventDispatcherWin32);
|
||||
|
||||
if (d->getMessageHook)
|
||||
UnhookWindowsHookEx(d->getMessageHook);
|
||||
d->getMessageHook = 0;
|
||||
}
|
||||
|
||||
QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent)
|
||||
: QAbstractEventDispatcher(*new QEventDispatcherWin32Private, parent)
|
||||
{
|
||||
@ -582,10 +547,6 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
}
|
||||
}
|
||||
if (haveMessage) {
|
||||
// The Direct2d integration unsets getMessageHook. See QTBUG-42428
|
||||
if (!d->getMessageHook)
|
||||
(void) qt_GetMessageHook(0, PM_REMOVE, reinterpret_cast<LPARAM>(&msg));
|
||||
|
||||
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
|
||||
// Set result to 'true', if the message was sent by wakeUp().
|
||||
if (msg.wParam == WMWP_QT_FROMWAKEUP) {
|
||||
@ -1043,8 +1004,6 @@ void QEventDispatcherWin32::closingDown()
|
||||
d->timerDict.clear();
|
||||
|
||||
d->closingDown = true;
|
||||
|
||||
uninstallMessageHook();
|
||||
}
|
||||
|
||||
bool QEventDispatcherWin32::event(QEvent *e)
|
||||
|
@ -73,8 +73,6 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher
|
||||
|
||||
protected:
|
||||
void createInternalHwnd();
|
||||
void installMessageHook();
|
||||
void uninstallMessageHook();
|
||||
|
||||
public:
|
||||
explicit QEventDispatcherWin32(QObject *parent = 0);
|
||||
@ -115,7 +113,6 @@ protected:
|
||||
|
||||
private:
|
||||
friend LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
|
||||
friend LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int, WPARAM, LPARAM);
|
||||
};
|
||||
|
||||
struct QSockNot {
|
||||
@ -169,7 +166,6 @@ public:
|
||||
|
||||
// internal window handle used for socketnotifiers/timers/etc
|
||||
HWND internalHwnd;
|
||||
HHOOK getMessageHook;
|
||||
|
||||
// for controlling when to send posted events
|
||||
QAtomicInt wakeUps;
|
||||
|
@ -63,7 +63,6 @@ public:
|
||||
QWindowsDirect2DEventDispatcher(QObject *parent = nullptr)
|
||||
: QWindowsGuiEventDispatcher(parent)
|
||||
{
|
||||
uninstallMessageHook(); // ### Workaround for QTBUG-42428
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user