Windows XP style: Fix warnings wrt retrieving HANDLE from 0-window.

Exclude invisible top level dialogs for whom a native
dialog is being shown from top-level search.

Change-Id: Ia94599905457d81d342c14d09ad0b0fc89ec4ab1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-02-06 09:38:48 +01:00 committed by Qt by Nokia
parent 1d18fd0164
commit 3282b060d1

View File

@ -337,10 +337,11 @@ HWND QWindowsXPStylePrivate::winId(const QWidget *widget)
if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(const_cast<QWidget *>(widget)))
return hwnd;
const QWidgetList toplevels = QApplication::topLevelWidgets();
if (!toplevels.isEmpty())
if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevels.front()))
return topLevelHwnd;
// Find top level with native window (there might be dialogs that do not have one).
foreach (const QWidget *toplevel, QApplication::topLevelWidgets())
if (toplevel->windowHandle())
if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevel))
return topLevelHwnd;
if (QDesktopWidget *desktop = qApp->desktop())
if (const HWND desktopHwnd = QApplicationPrivate::getHWNDForWidget(desktop))