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 .