From: Heeyong Song Date: Fri, 7 Apr 2017 10:53:52 +0000 (+0900) Subject: [3.0] Fix disconnection issue of signal X-Git-Tag: accepted/tizen/3.0/common/20170412.110709^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F124474%2F1;p=platform%2Fcore%2Fuifw%2Fdali-core.git [3.0] Fix disconnection issue of signal The item is not removed from mSignalConnections until the sinal is emitted. Changed to remove the item if the function is not called from Emit(). Change-Id: I954b7494f5063c520b91a3f39d707c4e396b2711 --- diff --git a/dali/public-api/signals/base-signal.cpp b/dali/public-api/signals/base-signal.cpp index 8d759e7..233981c 100644 --- a/dali/public-api/signals/base-signal.cpp +++ b/dali/public-api/signals/base-signal.cpp @@ -271,10 +271,19 @@ void BaseSignal::DeleteConnection( std::size_t connectionIndex ) SignalConnection* connection( mSignalConnections[ connectionIndex ] ); delete connection; - // IMPORTANT - do not remove from items from mSignalConnections, set to NULL instead. - // Signal Emit() methods require that connection count is not reduced while iterating - // i.e. DeleteConnection can be called from within callbacks, while iterating through mSignalConnections. - mSignalConnections[ connectionIndex ] = NULL; + if( mEmittingFlag ) + { + // IMPORTANT - do not remove from items from mSignalConnections, set to NULL instead. + // Signal Emit() methods require that connection count is not reduced while iterating + // i.e. DeleteConnection can be called from within callbacks, while iterating through mSignalConnections. + mSignalConnections[ connectionIndex ] = NULL; + } + else + { + // If application connects and disconnects without the signal never emitting, + // the mSignalConnections vector keeps growing and growing as CleanupConnections() is done from Emit. + mSignalConnections.Erase( mSignalConnections.Begin() + connectionIndex ); + } } void BaseSignal::CleanupConnections()