From 3b4f1677095af67a063c6c5c595ad176cdee0427 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 30 Oct 2023 17:08:39 +0100 Subject: [PATCH] always sending ( ot posting ) animator events. Otherwise we might be one updateNode cycle too late --- src/controls/QskHintAnimator.cpp | 48 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/controls/QskHintAnimator.cpp b/src/controls/QskHintAnimator.cpp index d9dc82f00..cec53ccd9 100644 --- a/src/controls/QskHintAnimator.cpp +++ b/src/controls/QskHintAnimator.cpp @@ -76,20 +76,28 @@ static inline QVariant qskAligned05( const QVariant& value ) #endif -static inline bool qskCheckReceiverThread( const QObject* receiver ) +static inline void qskSendAnimatorEvent( + const QskAspect aspect, int index, bool on, QObject* receiver ) { - /* - QskInputPanelSkinlet changes the skin state, what leads to - sending events from the wrong thread. Until we have fixed it - let's block sending the event to avoid running into assertions - in QCoreApplication::sendEvent - */ - - const QThread* thread = receiver->thread(); - if ( thread == nullptr ) - return true; + const auto state = on ? QskAnimatorEvent::Started : QskAnimatorEvent::Terminated; - return ( thread == QThread::currentThread() ); + const auto thread = receiver->thread(); + if ( thread && ( thread != QThread::currentThread() ) ) + { + /* + QskInputPanelSkinlet changes the skin state, what leads to + sending events from the wrong thread. We can't use + QCoreApplication::sendEvent then, TODO ... + */ + + auto event = new QskAnimatorEvent( aspect, index, state ); + QCoreApplication::postEvent( receiver, event ); + } + else + { + QskAnimatorEvent event( aspect, index, state ); + QCoreApplication::sendEvent( receiver, &event ); + } } QskHintAnimator::QskHintAnimator() noexcept @@ -338,11 +346,7 @@ void QskHintAnimatorTable::start( QskControl* control, animator->start(); - if ( qskCheckReceiverThread( control ) ) - { - QskAnimatorEvent event( aspect, index, QskAnimatorEvent::Started ); - QCoreApplication::sendEvent( control, &event ); - } + qskSendAnimatorEvent( aspect, index, true, control ); } const QskHintAnimator* QskHintAnimatorTable::animator( QskAspect aspect, int index ) const @@ -390,15 +394,7 @@ bool QskHintAnimatorTable::cleanup() it = animators.erase( it ); if ( control ) - { - if ( qskCheckReceiverThread( control ) ) - { - auto event = new QskAnimatorEvent( - aspect, index, QskAnimatorEvent::Terminated ); - - QCoreApplication::postEvent( control, event ); - } - } + qskSendAnimatorEvent( aspect, index, false, control ); } else {