From 07b6ad0e7a38955d0bb2afb12706b7b014cfa9fa Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 8 Jan 2019 17:08:50 +0100 Subject: [PATCH] workaround for a dangling pointer usage in QQuickWindowPrivate::polishItems added --- src/controls/QskControl.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/controls/QskControl.cpp b/src/controls/QskControl.cpp index c7e11999..837e3197 100644 --- a/src/controls/QskControl.cpp +++ b/src/controls/QskControl.cpp @@ -1697,8 +1697,24 @@ void QskControl::itemChange( QQuickItem::ItemChange change, qskFilterWindow( value.window ); } - QskWindowChangeEvent event( - qskReleasedWindowCounter->window(), value.window ); +#if 1 + auto oldWindow = qskReleasedWindowCounter->window(); + if ( oldWindow && ( oldWindow->activeFocusItem() == this ) ) + { + /* + When deleting the activeFocusItem inside of QQuickItem::polish + we run into crashes because of QQuickWindow::activeFocusItem() + becomes a dangling pointer being used at the end of + QQuickWindowPrivate::polishItems. + The crash becomes less likely since + */ + + QQuickWindowPrivate::get( oldWindow )->clearFocusInScope( + qskNearestFocusScope( this ), this, Qt::OtherFocusReason ); + } +#endif + + QskWindowChangeEvent event( oldWindow, value.window ); QCoreApplication::sendEvent( this, &event ); break;