avoiding a Qt assertion, by doing the check before

This commit is contained in:
Uwe Rathmann 2019-02-04 18:22:22 +01:00
parent 724c1e4a66
commit 722fb8511c

View File

@ -12,6 +12,7 @@
QSK_QT_PRIVATE_BEGIN QSK_QT_PRIVATE_BEGIN
#include <private/qquickwindow_p.h> #include <private/qquickwindow_p.h>
#include <private/qquickitem_p.h>
QSK_QT_PRIVATE_END QSK_QT_PRIVATE_END
QSK_SUBCONTROL( QskPopup, Overlay ) QSK_SUBCONTROL( QskPopup, Overlay )
@ -33,10 +34,16 @@ static void qskSetFocus( QQuickItem* item, bool on )
auto dw = QQuickWindowPrivate::get( item->window() ); auto dw = QQuickWindowPrivate::get( item->window() );
if ( on ) if ( on )
{
dw->setFocusInScope( scope, item, Qt::PopupFocusReason ); dw->setFocusInScope( scope, item, Qt::PopupFocusReason );
}
else else
{
// to avoid an assertion we have to check if we have the subFocus
if ( QQuickItemPrivate::get( scope )->subFocusItem == item )
dw->clearFocusInScope( scope, item, Qt::PopupFocusReason ); dw->clearFocusInScope( scope, item, Qt::PopupFocusReason );
} }
}
} }
static inline void qskSendPopupEvent( static inline void qskSendPopupEvent(