From 9c73ad5ecec2923563dad00d0c54929a33144e26 Mon Sep 17 00:00:00 2001 From: Cheng-Shiun Tsai Date: Wed, 11 Nov 2020 12:59:23 +0000 Subject: [PATCH] Use existing callback ID for recurring callbacks Owner of callback object keep track of callback id, this id is used in RemoveIdle(); The current Impl::OnIdle() will fire callbacks, if it's recurring callback object, assigned a new id without telling the owner Therefore when the owner needs to RemoveIdle() the owner gives out-of-dated id. Changing the code to reuse callback id in recurring callback case to be consistent with the owner. Change-Id: I9e891f271825dde1228be3298a85110059e4bceb --- dali/internal/adaptor/android/framework-android.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dali/internal/adaptor/android/framework-android.cpp b/dali/internal/adaptor/android/framework-android.cpp index f91f596..3212f4d 100644 --- a/dali/internal/adaptor/android/framework-android.cpp +++ b/dali/internal/adaptor/android/framework-android.cpp @@ -180,7 +180,7 @@ struct Framework::Impl { if ( callback() ) // keep the callback { - AddIdle( callback.timeout, callback.data, callback.callback ); + AddIdle( callback.timeout, callback.data, callback.callback, callback.id ); } } @@ -199,21 +199,30 @@ struct Framework::Impl } } - unsigned int AddIdle( int timeout, void* data, bool ( *callback )( void *data ) ) + unsigned int AddIdle( int timeout, void* data, bool ( *callback )( void *data ) , unsigned int existingId = 0 ) { - ++mIdleId; - if( mIdleId == 0 ) + unsigned int chosenId; + if (existingId) + { + chosenId = existingId; + } + else { ++mIdleId; + if( mIdleId == 0 ) + { + ++mIdleId; + } + chosenId = mIdleId; } - mIdleCallbacks.push( IdleCallback( timeout, mIdleId, data, callback ) ); + mIdleCallbacks.push( IdleCallback( timeout, chosenId, data, callback ) ); // To wake up the idle pipe and to trigger OnIdle int8_t msg = 1; write( mIdleWritePipe, &msg, sizeof( msg ) ); - return mIdleId; + return chosenId; } void RemoveIdle( unsigned int id ) -- 2.7.4