Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74091

Cannot detach window from its window container

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.1
    • GUI: Window management
    • 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`

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            christian_gagneraud_navico Christian Gagneraud
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes