From 76e61eba0d87b850b310fb61519e7d7e7a667125 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 11 Mar 2021 17:32:59 +0100 Subject: [PATCH] clenaup of the activeFocusItem fixed for Qt 5.15 --- src/controls/QskQuickItem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/controls/QskQuickItem.cpp b/src/controls/QskQuickItem.cpp index 73a3d31f..5be829f3 100644 --- a/src/controls/QskQuickItem.cpp +++ b/src/controls/QskQuickItem.cpp @@ -732,8 +732,16 @@ void QskQuickItem::itemChange( QQuickItem::ItemChange change, we might end up with having a dangling pointer for oldWindow->activeFocusItem(). */ - QQuickWindowPrivate::get( oldWindow )->clearFocusInScope( - qskNearestFocusScope( this ), this, Qt::OtherFocusReason ); + + auto wd = QQuickWindowPrivate::get( oldWindow ); + if ( auto scope = qskNearestFocusScope( this ) ) + { + wd->clearFocusInScope( scope, this, Qt::OtherFocusReason ); + } + else + { + wd->activeFocusItem = nullptr; + } } #endif