Fix floating dock widget having the wrong parent
When dragging out a tabbed group which contains placeholder for floating QDockWidget, the floating QDockWidget would not be reparented to the new QDockWidgetGroupWindow. That's because QDockAreaLayoutInfo::reparentWidgets does not reparent floating widget (because of the item.skip test) However, we need to be careful when reparenting to pass the flags so it does not get docked. Also do not reparent QDockWidgetGroupWindow which may end up temporarily in the layout during animation when dragging a QDockWidgetGroupWindow onto another. Step to reproduce a crash that if fixed by this patch (with the mainwindow example): 1. Enable QMainWindow::GroupedDragging from the "Main window" menu 2. Add a new dock widget, "Foo", from the "Dock Widgets" 3. Tab "Foo" together with the black dock widget 4. Drag "Foo" out. (Now, Foo is still a child of the QMainWindow, and is still in the layout as tabbed, but is skipped) 5. Drag the black dockwidget out. (This, in fact, crates a QDockWidgetGroupWindow which contains the black dockwidget and the floating "Foo", but since "Foo" is floating, it is not reparented) 6. Destroy "Foo" using the "Dock Widgets" menu. (Since Foo's parent is the QMainWindow, it is not removed from the QDockWidgetGroupWindow's layout, which will cause crash on the next relayout)" This commits amends commits d57bb19902f863fc6db07674f6bd8881b0886b39 and 0feeb6f6d2cfaa964763ca1fcab65672812b4eef Change-Id: I600a56cdd889435b83d2b740598a24d81059bf44 Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
This commit is contained in:
parent
97be8253fb
commit
ee84af00d1
@ -2092,15 +2092,15 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)
|
||||
const QDockAreaLayoutItem &item = item_list.at(i);
|
||||
if (item.flags & QDockAreaLayoutItem::GapItem)
|
||||
continue;
|
||||
if (item.skip())
|
||||
continue;
|
||||
if (item.subinfo)
|
||||
item.subinfo->reparentWidgets(parent);
|
||||
if (item.widgetItem) {
|
||||
QWidget *w = item.widgetItem->widget();
|
||||
if (qobject_cast<QDockWidgetGroupWindow *>(w))
|
||||
continue;
|
||||
if (w->parent() != parent) {
|
||||
bool hidden = w->isHidden();
|
||||
w->setParent(parent);
|
||||
w->setParent(parent, w->windowFlags());
|
||||
if (!hidden)
|
||||
w->show();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user