[NUI] Fix Animation Dispose() to make local variable of Animation instance make worki...
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 5 Feb 2020 02:09:57 +0000 (11:09 +0900)
committerGitHub <noreply@github.com>
Wed, 5 Feb 2020 02:09:57 +0000 (11:09 +0900)
- NUI Animation class is binding to DALi native Animation class.
- Animation class inherits from BaseHandle class so it has a reference count.
- In NUI side, if the Animation class is instanced in local scope, it is disposed automatically by DisposeQueue. Here the reference count of native DALi Animation is decreased and it will be managed by smart pointer so this is not a matter in NUI side.
- NUI Animation Dispose() need care only the events which are connected to native DALi, so event handlers of Finished and ProgressReached are certainly disconnected.
- Animation which has been created as local variable will work properly. (ex: if LoopCount is set to 100 and it is even local variable, it will animate 100 times and stop normally.)

src/Tizen.NUI/src/public/Animation.cs

index 383c20a..59fa58a 100755 (executable)
@@ -1283,28 +1283,20 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         protected override void Dispose(DisposeTypes type)
         {
-            if (this != null)
+            if (disposed)
             {
-                if (_animationFinishedEventCallback != null)
-                {
-                    FinishedSignal().Disconnect(_finishedCallbackOfNative);
-                }
-
-                if (_animationProgressReachedEventCallback != null)
-                {
-
-                    ProgressReachedSignal().Disconnect(_animationProgressReachedEventCallback);
-                }
+                return;
             }
 
-            if(disposed)
+            if (_finishedCallbackOfNative != null)
             {
-                return;
+                FinishedSignal().Disconnect(_finishedCallbackOfNative);
             }
 
-            if (this != null)
+            if (_animationProgressReachedEventCallback != null)
             {
-                this.Clear();
+
+                ProgressReachedSignal().Disconnect(_animationProgressReachedEventCallback);
             }
 
             base.Dispose(type);