using QQuickItemPrivate::inDestructor for Qt >= 6.5 instead of the
componentComplete hack done in ~QskQuickItem
This commit is contained in:
parent
9de8663f93
commit
346aff98d1
|
@ -103,7 +103,7 @@ void QskMainView::focusInEvent( QFocusEvent* event )
|
|||
{
|
||||
if ( auto focusItem = nextItemInFocusChain( true ) )
|
||||
{
|
||||
if ( qskIsItemComplete( focusItem )
|
||||
if ( !qskIsItemInDestructor( focusItem )
|
||||
&& qskIsAncestorOf( this, focusItem ) )
|
||||
{
|
||||
focusItem->setFocus( true );
|
||||
|
|
|
@ -527,7 +527,7 @@ void QskPopup::focusInEvent( QFocusEvent* event )
|
|||
|
||||
if ( auto focusItem = nextItemInFocusChain( true ) )
|
||||
{
|
||||
if ( qskIsItemComplete( focusItem )
|
||||
if ( !qskIsItemInDestructor( focusItem )
|
||||
&& qskIsAncestorOf( this, focusItem ) )
|
||||
{
|
||||
focusItem->setFocus( true );
|
||||
|
|
|
@ -47,6 +47,21 @@ bool qskIsItemComplete( const QQuickItem* item )
|
|||
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 )
|
||||
{
|
||||
if ( item == nullptr || child == nullptr )
|
||||
|
|
|
@ -24,6 +24,7 @@ template< typename T > class QList;
|
|||
of QQuickItem.
|
||||
*/
|
||||
|
||||
QSK_EXPORT bool qskIsItemInDestructor( const QQuickItem* );
|
||||
QSK_EXPORT bool qskIsItemComplete( const QQuickItem* );
|
||||
QSK_EXPORT bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child );
|
||||
QSK_EXPORT bool qskIsTabFence( const QQuickItem* );
|
||||
|
|
|
@ -180,6 +180,11 @@ QskQuickItem::~QskQuickItem()
|
|||
We set componentComplete to false, so that operations
|
||||
that are triggered by detaching the item from its parent
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue