From b6b5de9907479d9c52ad12d3adc0952192cac492 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@digia.com>
Date: Wed, 10 Jul 2013 14:12:06 +0200
Subject: [PATCH] Set native parent handle property on widget.

QWidgetWindow may not exist at that point.

Task-number: QTBUG-31672
Task-number: QTBUG-32343
Change-Id: Ia74e4d9250704ac97aac17b892bc8de9a6d535fb
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
---
 src/activeqt/control/qaxserverbase.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index d0b0db4d..daf2d771 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -1382,18 +1382,16 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
 	    if(wParam) {
 	        that->internalCreate();
 	        if (!that->stayTopLevel) {
-                QWindow *widgetWindow = that->qt.widget->windowHandle();
                 // Set this property on window to pass the native handle to platform plugin,
                 // so that it can create the window with proper flags instead of thinking
                 // it is toplevel.
-                if (widgetWindow) {
-                    widgetWindow->setProperty("_q_embedded_native_parent_handle", WId(that->m_hWnd));
+                that->qt.widget->setProperty("_q_embedded_native_parent_handle", WId(that->m_hWnd));
 
+                if (QWindow *widgetWindow = that->qt.widget->windowHandle()) {
                     // If embedded widget is native, such as QGLWidget, it may have already created
                     // a window before now, probably as an undesired toplevel. In that case set the
                     // proper parent window and set the window frameless to position it correctly.
-                    if (widgetWindow
-                        && that->qt.widget->testAttribute(Qt::WA_WState_Created)
+                    if (that->qt.widget->testAttribute(Qt::WA_WState_Created)
                         && !that->qt.widget->isVisible()) {
                         HWND h = static_cast<HWND>(QGuiApplication::platformNativeInterface()->
                             nativeResourceForWindow("handle", widgetWindow));
-- 
GitLab