always sending ( ot posting ) animator events. Otherwise we might be one

updateNode cycle too late
This commit is contained in:
Uwe Rathmann 2023-10-30 17:08:39 +01:00
parent b5fb6d80ad
commit 3b4f167709
1 changed files with 22 additions and 26 deletions

View File

@ -76,20 +76,28 @@ static inline QVariant qskAligned05( const QVariant& value )
#endif #endif
static inline bool qskCheckReceiverThread( const QObject* receiver ) static inline void qskSendAnimatorEvent(
const QskAspect aspect, int index, bool on, QObject* receiver )
{
const auto state = on ? QskAnimatorEvent::Started : QskAnimatorEvent::Terminated;
const auto thread = receiver->thread();
if ( thread && ( thread != QThread::currentThread() ) )
{ {
/* /*
QskInputPanelSkinlet changes the skin state, what leads to QskInputPanelSkinlet changes the skin state, what leads to
sending events from the wrong thread. Until we have fixed it sending events from the wrong thread. We can't use
let's block sending the event to avoid running into assertions QCoreApplication::sendEvent then, TODO ...
in QCoreApplication::sendEvent
*/ */
const QThread* thread = receiver->thread(); auto event = new QskAnimatorEvent( aspect, index, state );
if ( thread == nullptr ) QCoreApplication::postEvent( receiver, event );
return true; }
else
return ( thread == QThread::currentThread() ); {
QskAnimatorEvent event( aspect, index, state );
QCoreApplication::sendEvent( receiver, &event );
}
} }
QskHintAnimator::QskHintAnimator() noexcept QskHintAnimator::QskHintAnimator() noexcept
@ -338,11 +346,7 @@ void QskHintAnimatorTable::start( QskControl* control,
animator->start(); animator->start();
if ( qskCheckReceiverThread( control ) ) qskSendAnimatorEvent( aspect, index, true, control );
{
QskAnimatorEvent event( aspect, index, QskAnimatorEvent::Started );
QCoreApplication::sendEvent( control, &event );
}
} }
const QskHintAnimator* QskHintAnimatorTable::animator( QskAspect aspect, int index ) const const QskHintAnimator* QskHintAnimatorTable::animator( QskAspect aspect, int index ) const
@ -390,15 +394,7 @@ bool QskHintAnimatorTable::cleanup()
it = animators.erase( it ); it = animators.erase( it );
if ( control ) if ( control )
{ qskSendAnimatorEvent( aspect, index, false, control );
if ( qskCheckReceiverThread( control ) )
{
auto event = new QskAnimatorEvent(
aspect, index, QskAnimatorEvent::Terminated );
QCoreApplication::postEvent( control, event );
}
}
} }
else else
{ {