From 55ea8490f9bd4a7148dc702baf6bb4a2ad3bdcc6 Mon Sep 17 00:00:00 2001
From: Michail Vourlakos <mvourlakos@gmail.com>
Date: Sat, 14 Jan 2017 20:49:58 +0200
Subject: [PATCH] fix #51,protect add task animation more

--in case the add animation is stuck in the
middle and not run until the end, this could
cause also the #51 issue
---
 plasmoid/contents/ui/TaskDelegate.qml | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/plasmoid/contents/ui/TaskDelegate.qml b/plasmoid/contents/ui/TaskDelegate.qml
index 255d0f47d..030b4ba07 100644
--- a/plasmoid/contents/ui/TaskDelegate.qml
+++ b/plasmoid/contents/ui/TaskDelegate.qml
@@ -880,8 +880,16 @@ MouseArea{
     SequentialAnimation{
         id:showWindowAnimation
         property int speed: windowSystem.compositingActive ? root.durationTime* (1.2*units.longDuration) : 0
+        property bool animationSent: false
 
-        ScriptAction{script:{root.signalAnimationsNeedLength(1)}}
+        ScriptAction{
+            script:{
+                if (!showWindowAnimation.animationSent) {
+                    showWindowAnimation.animationSent = true;
+                    root.signalAnimationsNeedLength(1);
+                }
+            }
+        }
 
         PropertyAnimation {
             target: wrapper
@@ -912,8 +920,6 @@ MouseArea{
             }
         }
 
-        ScriptAction{script:{root.signalAnimationsNeedLength(-1)}}
-
         onStopped: {
             if(mainItemContainer.isWindow || mainItemContainer.isStartup){
                 taskInitComponent.createObject(wrapper);
@@ -922,6 +928,11 @@ MouseArea{
                 }
             }
             mainItemContainer.inAnimation = false;
+
+            if (showWindowAnimation.animationSent) {
+                root.signalAnimationsNeedLength(-1);
+                showWindowAnimation.animationSent = false;
+            }
         }
 
         function init(){