Avoid debug assert when Timer is destroyed 52/151652/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 21 Sep 2017 10:33:42 +0000 (11:33 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 21 Sep 2017 10:45:07 +0000 (11:45 +0100)
item-view.example and clipping.example crash with debug builds without this patch

Change-Id: Icacb213e435cdc831da24e146cc50f47a29b3e37

adaptors/common/event-loop/ecore/ecore-timer-impl.cpp
adaptors/common/timer-impl.h

index d392001..a05b13f 100644 (file)
@@ -79,9 +79,7 @@ Timer::Timer( unsigned int milliSec )
 
 Timer::~Timer()
 {
-  // stop timers
-  Stop();
-
+  ResetTimerData();
   delete mImpl;
 }
 
@@ -102,11 +100,7 @@ void Timer::Stop()
   // Timer should be used in the event thread
   DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
 
-  if (mImpl->mId != NULL)
-  {
-    ecore_timer_del(mImpl->mId);
-    mImpl->mId = NULL;
-  }
+  ResetTimerData();
 }
 
 void Timer::SetInterval( unsigned int interval )
@@ -159,6 +153,15 @@ Dali::Timer::TimerSignalType& Timer::TickSignal()
   return mTickSignal;
 }
 
+void Timer::ResetTimerData()
+{
+  if (mImpl->mId != NULL)
+  {
+    ecore_timer_del(mImpl->mId);
+    mImpl->mId = NULL;
+  }
+}
+
 bool Timer::IsRunning() const
 {
   return mImpl->mId != NULL;
index e8bc456..b5b105b 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_TIMER_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -99,6 +99,11 @@ private: // Implementation
   Timer( const Timer& );
   Timer& operator=( const Timer& );
 
+  /**
+   * Resets any stored timer data.
+   */
+  void ResetTimerData();
+
 private: // Data
 
   Dali::Timer::TimerSignalType mTickSignal;