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>
This commit is contained in:
parent
a473103734
commit
da3a600824
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user