[4.0] Fix callback manager issue
[platform/core/uifw/dali-adaptor.git] / adaptors / common / event-loop / ecore / ecore-callback-manager.cpp
old mode 100644 (file)
new mode 100755 (executable)
index c130bda..96ea7d4
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -140,19 +140,23 @@ bool EcoreCallbackManager::AddIdleCallback( CallbackBase* callback )
 
 void EcoreCallbackManager::RemoveIdleCallback( CallbackBase* callback )
 {
-  for( CallbackList::iterator it = mCallbackContainer.begin(),
-         endIt = mCallbackContainer.end();
-       it != endIt;
-       ++it )
+  CallbackList::iterator it = mCallbackContainer.begin();
+
+  while( mCallbackContainer.end() != it )
   {
     CallbackData* data = *it;
 
     if( data->mCallback == callback )
     {
-      // remove callback data from the container.
-      CallbackBase::Execute( *data->mRemoveFromContainerFunction, data );
-
+      it = mCallbackContainer.erase( it );
       ecore_idler_del( data->mIdler );
+
+      // delete our data
+      delete data;
+    }
+    else
+    {
+      it++;
     }
   }
 }