summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-05-15 08:21:00 +0200
committerAndy Shaw <andy.shaw@qt.io>2017-05-15 07:37:17 +0000
commit0544c2b41fdb0a7d7efc9db701bac561e0edf1f3 (patch)
tree405a8f041842ea1a3d9996045a311f30ddf5926b
parent9be1fd20859e90c379d517eaf6dfeb55604cd2fa (diff)
downloadqtactiveqt-0544c2b41fdb0a7d7efc9db701bac561e0edf1f3.tar.gz
Unset widget window's parent when WM_DESTROY is sent to prevent a crash
When a control is activated and deactivated in Powerpoint then it will cause the ActiveX window hosting the QWidget to be destroyed. In this case we need to set the parent of this widget's own QWindow's HWND to be 0 so it does not reference the deleted window. This reflects the handling in WM_SHOWWINDOW where the parent is set for the widget's own QWindow's HWND. Change-Id: Ie32d408782cdf94a98cb13eda49f6ccf73cccd51 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/activeqt/control/qaxserverbase.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index f2d4262..9efded2 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -1400,8 +1400,13 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
case WM_QUERYENDSESSION:
case WM_DESTROY:
if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) {
- if (that->qt.widget)
+ if (that->qt.widget) {
that->qt.widget->hide();
+ if (QWindow *widgetWindow = that->qt.widget->windowHandle()) {
+ if (HWND h = reinterpret_cast<HWND>(widgetWindow->winId()))
+ ::SetParent(h, 0);
+ }
+ }
}
break;