diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-01-29 16:48:25 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-02-06 15:22:37 +0000 |
commit | 8657988dd4074377a2131dee300ca35004869e3e (patch) | |
tree | 1bee9244dfe95bf2c0171cddc81f33101ee7bfdd /src | |
parent | 14fcbc7c73cc0498b5614451be3720f2615b8a61 (diff) |
Refactor QWinEventFilter.
- Fix invocation of static methods.
- Prevent it from enforcing native windows in
findWindow().
Change-Id: I08d88f7753968459b8f77e24bd188cbbf982c21b
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/winextras/qwineventfilter.cpp | 15 |
1 files 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<WId>(handle)) { - w = list.at(i); - break; - } + const WId wid = reinterpret_cast<WId>(handle); + foreach (QWindow *topLevel, QGuiApplication::topLevelWindows()) { + if (topLevel->handle() && topLevel->winId() == wid) + return topLevel; } - return w; + return Q_NULLPTR; } |