Fix dock widget having the wrong parent after a drag

When dragging a dock widget from a floating group to the main window
reparentWidgets() is supposed to be called. It's usually triggered
by some unrelated event, like a LayoutRequest.

Instead of relying on luck for reparentWidgets() to get called be
explicit, otherwise the dock widget that was dropped into main window
will still have as parent the floating group window.

The item.skip() condition seems overly restrictive.

Task-number: QTBUG-58036
Change-Id: I65b5699e1acb6ca9bedb10620daa055fa9d91943
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Sergio Martins 2017-01-09 22:42:30 +00:00 committed by Sérgio Martins
parent 52d9fd74b1
commit 0feeb6f6d2

View File

@ -2092,7 +2092,7 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)
const QDockAreaLayoutItem &item = item_list.at(i);
if (item.flags & QDockAreaLayoutItem::GapItem)
continue;
if (item.skip())
if (!item.widgetItem && item.skip())
continue;
if (item.subinfo)
item.subinfo->reparentWidgets(parent);
@ -2608,7 +2608,9 @@ QLayoutItem *QDockAreaLayout::plug(const QList<int> &path)
Q_ASSERT(!path.isEmpty());
const int index = path.first();
Q_ASSERT(index >= 0 && index < QInternal::DockCount);
return docks[index].plug(path.mid(1));
QLayoutItem *item = docks[index].plug(path.mid(1));
docks[index].reparentWidgets(mainWindow);
return item;
}
QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path)