diff options
-rw-r--r-- | src/widgets/kernel/qwidget_qpa.cpp | 2 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 3b6127e4e7..3281e0c6f7 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -70,7 +70,7 @@ void q_createNativeChildrenAndSetParent(const QWidget *parentWidget) const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); if (childWidget) { // should not be necessary if (childWidget->testAttribute(Qt::WA_NativeWindow)) { - if (!childWidget->windowHandle()) + if (!childWidget->internalWinId()) childWidget->winId(); if (childWidget->windowHandle()) { QWindow *parentWindow = childWidget->nativeParentWidget()->windowHandle(); diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 1bbbfd610e..d6b7fc20ed 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -94,6 +94,8 @@ private slots: #ifndef QT_NO_DRAGANDDROP void tst_dnd(); #endif + + void tst_qtbug35600(); }; void tst_QWidget_window::initTestCase() @@ -568,5 +570,33 @@ void tst_QWidget_window::tst_dnd() } #endif +void tst_QWidget_window::tst_qtbug35600() +{ + QWidget w; + w.show(); + + QWidget *wA = new QWidget; + QHBoxLayout *layoutA = new QHBoxLayout; + + QWidget *wB = new QWidget; + layoutA->addWidget(wB); + + QWidget *wC = new QWidget; + layoutA->addWidget(wC); + + wA->setLayout(layoutA); + + QWidget *wD = new QWidget; + wD->setAttribute(Qt::WA_NativeWindow); + wD->setParent(wB); + + QWidget *wE = new QWidget(wC, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowTransparentForInput); + wE->show(); + + wA->setParent(&w); + + // QTBUG-35600: program may crash here or on exit +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" |