Fix regression in debug build & test cases 60/24860/1
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 23 Jul 2014 13:29:03 +0000 (14:29 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 23 Jul 2014 13:30:42 +0000 (14:30 +0100)
[Problem] index going out of bounds
[Cause] using wrong method
[Solution] correct algorithm

Change-Id: I2cd31458534fa8886b7ff27e711fe65e161a1b50

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

index cb21f43..71ff408 100644 (file)
@@ -289,18 +289,21 @@ void BaseSignal::CleanupConnections()
   // only do something if there are items
   if( total > 0 )
   {
-    std::size_t removed = 0;
+    std::size_t index = 0;
+    // process the whole vector
     for( std::size_t i = 0; i < total; ++i )
     {
-      if( mSignalConnections[ i ] == NULL )
+      if( mSignalConnections[ index ] == NULL )
       {
-        ++removed;
-        // swaps it to the end
-        mSignalConnections.Remove( mSignalConnections.Begin() + i );
+        // items will be moved so don't increase index (erase will decrease the count of vector)
+        mSignalConnections.Erase( mSignalConnections.Begin() + index );
+      }
+      else
+      {
+        // increase to next element
+        ++index;
       }
     }
-    // dont reallocate memory, just resize vector
-    mSignalConnections.Resize( total - removed );
   }
 }