Added missing newline chars to logging commands
[platform/core/uifw/dali-core.git] / dali / public-api / signals / base-signal.cpp
index cb21f43..8d759e7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,12 +29,6 @@ namespace
 
 const int INVALID_CALLBACK_INDEX = -1;
 
-// Predicate for std::remove_if algorithm
-bool IsNullPredicate(void* ptr)
-{
-  return ptr == NULL;
-}
-
 } // unnamed namespace
 
 namespace Dali
@@ -289,18 +283,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 )
+      {
+        // items will be moved so don't increase index (erase will decrease the count of vector)
+        mSignalConnections.Erase( mSignalConnections.Begin() + index );
+      }
+      else
       {
-        ++removed;
-        // swaps it to the end
-        mSignalConnections.Remove( mSignalConnections.Begin() + i );
+        // increase to next element
+        ++index;
       }
     }
-    // dont reallocate memory, just resize vector
-    mSignalConnections.Resize( total - removed );
   }
 }
 
@@ -317,7 +314,7 @@ BaseSignal::EmitGuard::EmitGuard( bool& flag )
   else
   {
     // mFlag is NULL when Emit() is called during Emit()
-    DALI_LOG_ERROR( "Cannot call Emit() from inside Emit()" );
+    DALI_LOG_ERROR( "Cannot call Emit() from inside Emit()\n" );
   }
 }