summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2017-03-21 13:43:28 +0100
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2017-03-22 14:28:51 +0000
commitee84af00d1ad28138a66ac422b1edb7be896512b (patch)
treebe840d6483c754ea3200435d71ec84f48651e30f /src/widgets
parent97be8253fbe9d9e4954b6d345e8fe64bd566a395 (diff)
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>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 8d9280ebb5..53dbe490dc 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -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();
}