QtWidgets: Fix wrong screen returned by newly added QWidgetPrivate::associatedScreen()

QWidgetPrivate::windowHandle() should not return nullptr from the
WindowHandleMode::Direct branch in case WindowHandleMode::Closest was
passed.

Ameds eed9a8fbd3.

Task-number: QTBUG-62094
Task-number: QTBUG-73231
Change-Id: Ia55fff15f0a499cef9525e53111ddd55b2e012d0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Friedemann Kleint 2019-07-02 15:28:20 +02:00
parent ee6b19042f
commit e40a139abf

View File

@ -1255,8 +1255,10 @@ void QWidgetPrivate::createRecursively()
QWindow *QWidgetPrivate::windowHandle(WindowHandleMode mode) const QWindow *QWidgetPrivate::windowHandle(WindowHandleMode mode) const
{ {
if (mode == WindowHandleMode::Direct || mode == WindowHandleMode::Closest) { if (mode == WindowHandleMode::Direct || mode == WindowHandleMode::Closest) {
if (QTLWExtra *x = maybeTopData()) if (QTLWExtra *x = maybeTopData()) {
return x->window; if (x->window != nullptr || mode == WindowHandleMode::Direct)
return x->window;
}
} }
if (mode == WindowHandleMode::Closest) { if (mode == WindowHandleMode::Closest) {
if (auto nativeParent = q_func()->nativeParentWidget()) { if (auto nativeParent = q_func()->nativeParentWidget()) {