From 8657988dd4074377a2131dee300ca35004869e3e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 29 Jan 2015 16:48:25 +0100 Subject: Refactor QWinEventFilter. - Fix invocation of static methods. - Prevent it from enforcing native windows in findWindow(). Change-Id: I08d88f7753968459b8f77e24bd188cbbf982c21b Reviewed-by: Joerg Bornemann --- src/winextras/qwineventfilter.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/winextras/qwineventfilter.cpp b/src/winextras/qwineventfilter.cpp index c04a9ed..a503f20 100644 --- a/src/winextras/qwineventfilter.cpp +++ b/src/winextras/qwineventfilter.cpp @@ -85,7 +85,7 @@ bool QWinEventFilter::nativeEventFilter(const QByteArray &, void *message, long if (event) { window = findWindow(msg->hwnd); if (window) - qApp->sendEvent(window, event); + QCoreApplication::sendEvent(window, event); delete event; } @@ -106,13 +106,10 @@ void QWinEventFilter::setup() QWindow *QWinEventFilter::findWindow(HWND handle) { - QWindow *w = 0; - QWindowList list = qApp->topLevelWindows(); - for (int i = 0; i < list.size(); i++) { - if (list.at(i)->winId() == reinterpret_cast(handle)) { - w = list.at(i); - break; - } + const WId wid = reinterpret_cast(handle); + foreach (QWindow *topLevel, QGuiApplication::topLevelWindows()) { + if (topLevel->handle() && topLevel->winId() == wid) + return topLevel; } - return w; + return Q_NULLPTR; } -- cgit v1.2.3