Fix notification of QDockWidget when it gets undocked

Before the patch the notification was emitted only when the docker
was attached to the panel or changed a position on it.

It looks like the old behavior was documented in a unittest,
so this patch might actually be a "behavior change".

Change-Id: Id3ffbd2018a8e68844d174328dd1c4ceb7fa01d3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Dmitry Kazakov 2018-12-06 16:16:27 +03:00
parent 92f9842732
commit 06b8644953
2 changed files with 7 additions and 1 deletions

View File

@ -1182,6 +1182,8 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (mwlayout)
emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
} else {
emit q->dockLocationChanged(Qt::NoDockWidgetArea);
}
}

View File

@ -670,7 +670,11 @@ void tst_QDockWidget::dockLocationChanged()
spy.clear();
dw.setFloating(true);
QTest::qWait(100);
QTRY_COMPARE(spy.count(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::NoDockWidgetArea);
spy.clear();
dw.setFloating(false);
QTRY_COMPARE(spy.count(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),