[3.0] Fix disconnection issue of signal 74/124474/1 accepted/tizen/3.0/common/20170412.110709 accepted/tizen/3.0/ivi/20170412.093510 accepted/tizen/3.0/mobile/20170412.092917 accepted/tizen/3.0/tv/20170412.093151 accepted/tizen/3.0/wearable/20170412.093254 submit/tizen_3.0/20170411.103942
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 7 Apr 2017 10:53:52 +0000 (19:53 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 11 Apr 2017 10:22:45 +0000 (19:22 +0900)
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

dali/public-api/signals/base-signal.cpp

index 8d759e7..233981c 100644 (file)
@@ -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()