diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-10-30 14:21:07 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-09 07:20:23 +0000 |
commit | da3a600824fa2f809fe2cdb317d528007c40eb43 (patch) | |
tree | 76432faa03aea454a4158f833cf8c558e6863226 /src/plugins/styles | |
parent | a473103734c8556b8c381910132184d6309c42d1 (diff) |
QWindowsXPStyle: Speed up level window loop in helper winId()
Rewrite the loop using QGuiApplication::allWindows() to avoid
the creation of temporary containers by
QApplication::topLevelWidgets() and expensive checks.
Task-number: QTBUG-64072
Change-Id: I56ef29b12f7bcbe274f3e00a6007d75d33f22b10
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/plugins/styles')
-rw-r--r-- | src/plugins/styles/windowsvista/qwindowsxpstyle.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index 1f7e223fe2..cf344c8f88 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -400,11 +400,10 @@ HWND QWindowsXPStylePrivate::winId(const QWidget *widget) return hwnd; // Find top level with native window (there might be dialogs that do not have one). - const auto topLevels = QApplication::topLevelWidgets(); - for (const QWidget *toplevel : topLevels) { - if (toplevel->windowHandle() && toplevel->windowHandle()->handle()) - if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevel)) - return topLevelHwnd; + const auto allWindows = QGuiApplication::allWindows(); + for (const QWindow *window : allWindows) { + if (window->isTopLevel() && window->type() != Qt::Desktop && window->handle() != nullptr) + return reinterpret_cast<HWND>(window->winId()); } return GetDesktopWindow(); |