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

Reparenting QTabWidget with a native window tab can cause crash

    XMLWordPrintable

Details

    • All
    • c956eb8ed (dev), 8ee25c66d (6.7), 169a2f212 (6.7.0), 2c0a4d6c5 (6.6), 9e2dcc749 (tqtc/lts-6.5)

    Description

      When a native window widget (child of another top-level window) is added as a tab to QTabWidget and then the QTabWidget is reparented to a new top-level window, the widget's top-level system extra window is not reparented to the new top-level window as expected. Due to this, when the old top-level window goes out of scope, the widget's extra window is destroyed and further access to the widget's window handle would result in a crash.

      Steps to Reproduce:

      1. Create a QWidget as a native window and parent it to another top-level native window.
      2. Add QWidget as a tab to a QTabWidget using QTabWidget::addTab
      3. Reparent the QTabWidget to a new top-level window aka newTLW using QWidget::setParent.
      4. Destroy the old top-level window.
      5. QWidget's top-level system extra window would be destroyed and the QWidget would contain a dangling pointer.

      Expected Behavior: 
      The QWidget's top-level system extra window should be reparented to the new top-level window when the QTabWidget is reparented.

      Actual Behavior:
      When the old top-level window goes out of scope, child windows associated with the old top-level window's extra are destroyed, including the system extra window. This leaves them QWidget with a dangling extra window pointer. Any future access to this window handle would result in a crash.

      Additional Notes
      A simple reproducer app is attached QTBUG-122747.zip .

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            kandass1 Senthil Kannan Kandaswamy
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes