Details
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:
- Create a QWidget as a native window and parent it to another top-level native window.
- Add QWidget as a tab to a QTabWidget using QTabWidget::addTab
- Reparent the QTabWidget to a new top-level window aka newTLW using QWidget::setParent.
- Destroy the old top-level window.
- 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
For Gerrit Dashboard: QTBUG-122747 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
544899,5 | Reparent QWindow children when reparenting QWidget | dev | qt/qtbase | Status: MERGED | +2 | 0 |
547868,4 | Reparent QWindow children when reparenting QWidget | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
549412,2 | Reparent QWindow children when reparenting QWidget | 6.7.0 | qt/qtbase | Status: MERGED | +2 | 0 |
549413,3 | Reparent QWindow children when reparenting QWidget | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |
549843,2 | Reparent QWindow children when reparenting QWidget | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |