Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.1
-
None
Description
I'm embedding a Qml Wayland compositor into a widget application using QWidget::createWindowContainer(), later i need to get rid of the container but i still need to keep the window around.
So i call window->setParent(nullptr) and delete the container.
The container will then delete the window. It should not, as per documentation:
The container takes over ownership of window. The window can be removed from the window container with a call to QWindow::setParent().
I've track down the crash, and it all boils down to ChildRemoved event not being sent to QWindowContainer. That is the only piece of code that nullify d->window.
https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qwindowcontainer.cpp.html#298
As d->window is not null, the window gets deleted by QWindowContainer dtor.
My current work around is to manually send a madeup child removed event before deleting the window container.
It doesn't seem to be specific to wayland, any embedded Qml window will crash.
Example: just hack the Qml 'embeddedinwidgets' example:
QWidget *container = QWidget::createWindowContainer(m_quickView); m_quickView->setParent(nullptr); delete container; container = QWidget::createWindowContainer(m_quickView);
And watch it crash, as `m_quickView` has just been deleted by `container`