Fix use after destruct for QWidgetWindow

The call to destroy() happened in QWindow destructor, after
̃QWidgetWindow destructor had run. This is to late since destroy calls
setVisible which ends up in QWidgetWindowPrivate which accesses
QWidgetWindow.

Calling destroy from ̃the QWidgetWindow destructor makes sure the object
is still alive when setVisible is called.

Tested manually by running the documentviewer demo as
given in the bug

Fixes: QTBUG-126456
Pick-to: 6.7 6.5
Change-Id: I2ca0384c453d59c5ffb9f3588d592701bebf3aa8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 9b99361698219a73ce1b54fe56497560e02b2229)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Even Oscar Andersen 2024-06-19 18:29:48 +02:00 committed by Qt Cherry-pick Bot
parent b792b40378
commit e596ce1285

View File

@ -170,6 +170,9 @@ QWidgetWindow::QWidgetWindow(QWidget *widget)
QWidgetWindow::~QWidgetWindow()
{
// destroy while we are still alive
destroy();
if (!m_widget)
return;