Fix QWindowsAccessible::GetWindow()
authorJan-Arve Saether <jan-arve.saether@nokia.com>
Thu, 22 Sep 2011 14:10:35 +0000 (16:10 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 3 Oct 2011 07:56:09 +0000 (09:56 +0200)
Since we added QAI::window() we now have a more reliable way of
getting hold of a HWND.

Change-Id: I330ecee67f041d5b204ef4bc1401ce4cc76de2b7
Reviewed-on: http://codereview.qt-project.org/5840
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
src/plugins/platforms/windows/qwindowsaccessibility.cpp

index 39452da..7434071 100644 (file)
@@ -1203,28 +1203,14 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::GetWindow(HWND *phwnd)
     if (!accessible->isValid())
         return E_UNEXPECTED;
 
-    QObject *o = accessible->object();
-    QWindow *window = qobject_cast<QWindow*>(o);
+    QWindow *window = accessible->window();
     if (!window)
-        window = QGuiApplication::topLevelWindows().first();
-
-
-    Q_ASSERT(window);
-    if (!o || !window)
         return E_FAIL;
 
-
-#ifdef Q_WS_QPA
-    //QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
-    //Q_ASSERT(platform);
-    //*phwnd = (HWND)platform->nativeResourceForWindow("handle", window);
-
-
-    return S_OK;
-#else
-    *phwnd = static_cast<QWidget*>(o)->effectiveWinId();
+    QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
+    Q_ASSERT(platform);
+    *phwnd = (HWND)platform->nativeResourceForWindow("handle", window);
     return S_OK;
-#endif
 }
 
 HRESULT STDMETHODCALLTYPE QWindowsAccessible::ContextSensitiveHelp(BOOL)