Merge branch 'master' into features/drawer

This commit is contained in:
Uwe Rathmann 2023-10-25 09:46:09 +02:00
commit 1b8ac518e2
5 changed files with 23 additions and 2 deletions

View File

@ -103,7 +103,7 @@ void QskMainView::focusInEvent( QFocusEvent* event )
{ {
if ( auto focusItem = nextItemInFocusChain( true ) ) if ( auto focusItem = nextItemInFocusChain( true ) )
{ {
if ( qskIsItemComplete( focusItem ) if ( !qskIsItemInDestructor( focusItem )
&& qskIsAncestorOf( this, focusItem ) ) && qskIsAncestorOf( this, focusItem ) )
{ {
focusItem->setFocus( true ); focusItem->setFocus( true );

View File

@ -539,7 +539,7 @@ void QskPopup::focusInEvent( QFocusEvent* event )
if ( auto focusItem = nextItemInFocusChain( true ) ) if ( auto focusItem = nextItemInFocusChain( true ) )
{ {
if ( qskIsItemComplete( focusItem ) if ( !qskIsItemInDestructor( focusItem )
&& qskIsAncestorOf( this, focusItem ) ) && qskIsAncestorOf( this, focusItem ) )
{ {
focusItem->setFocus( true ); focusItem->setFocus( true );

View File

@ -47,6 +47,21 @@ bool qskIsItemComplete( const QQuickItem* item )
return QQuickItemPrivate::get( item )->componentComplete; return QQuickItemPrivate::get( item )->componentComplete;
} }
bool qskIsItemInDestructor( const QQuickItem* item )
{
auto d = QQuickItemPrivate::get( item );
#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 )
return d->inDestructor;
#else
/*
QskQuickItem sets componentComplete to false in its destructor,
but for other items we will will return the wrong information
*/
return !d->componentComplete;
#endif
}
bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child ) bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child )
{ {
if ( item == nullptr || child == nullptr ) if ( item == nullptr || child == nullptr )

View File

@ -24,6 +24,7 @@ template< typename T > class QList;
of QQuickItem. of QQuickItem.
*/ */
QSK_EXPORT bool qskIsItemInDestructor( const QQuickItem* );
QSK_EXPORT bool qskIsItemComplete( const QQuickItem* ); QSK_EXPORT bool qskIsItemComplete( const QQuickItem* );
QSK_EXPORT bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child ); QSK_EXPORT bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child );
QSK_EXPORT bool qskIsTabFence( const QQuickItem* ); QSK_EXPORT bool qskIsTabFence( const QQuickItem* );

View File

@ -180,6 +180,11 @@ QskQuickItem::~QskQuickItem()
We set componentComplete to false, so that operations We set componentComplete to false, so that operations
that are triggered by detaching the item from its parent that are triggered by detaching the item from its parent
can be aware of the about-to-delete state. can be aware of the about-to-delete state.
Note, that since Qt >= 6.5 this information is stored
in QQuickItemPrivate::inDestructor.
s.a: qskIsItemInDestructor
*/ */
d_func()->componentComplete = false; d_func()->componentComplete = false;