diff ObjectiveTracker/Block.lua @ 46:aa693607b813

Block - use Animation:IsPlaying() to determine whether a block should be ignored during cleanup; fixes abandoned quest ghosts
author Nenue
date Tue, 26 Apr 2016 15:05:38 -0400
parents dd1ae565f559
children
line wrap: on
line diff
--- a/ObjectiveTracker/Block.lua	Tue Apr 26 14:57:18 2016 -0400
+++ b/ObjectiveTracker/Block.lua	Tue Apr 26 15:05:38 2016 -0400
@@ -141,33 +141,28 @@
     print('  |cFF00FF00('..source..')|r |cFF0088FF'..self.name..'|r.|cFF00FFBBusedBlocks['..block.posIndex..'] =|r', block:GetName())
   end
 
-    block.blockFadeOut:SetScript('OnFinished', blockFadeOut_OnFinished)
-    block:SetScript('OnHide', function(self)
-      fprint(self:GetName(), '|cFF00FF00HIDE|r', debugstack(1,3,1))
-      if(self.DebugTab:IsShown()) then
-        self.DebugTab:Hide()
-      end
-      self.blockFadeOut:SetScript('OnFinished', blockFadeOut_OnFinished)
-      self.isAnimating = nil
-    end)
+  block.blockFadeOut:SetScript('OnFinished', blockFadeOut_OnFinished)
+  block:SetScript('OnHide', function(self)
+    fprint(self:GetName(), '|cFF00FF00HIDE|r', debugstack(1,3,1))
+    if(self.DebugTab:IsShown()) then
+      self.DebugTab:Hide()
+    end
+    self.blockFadeOut:SetScript('OnFinished', blockFadeOut_OnFinished)
+  end)
   print('  used/free: |cFFFFFF00' .. #self.usedBlocks .. '|r/|cFF00FFFF'..#self.freeBlocks ..'|r')
   return block
 end
 
 --- begins a blockFadeOut animation and fires FreeBlock when that's done
 function Default:ClearBlock (block)
-  -- double ensure multiple finish scripts from firing
-  if block.isAnimating then
-    return
-  end
-  block.isAnimating = true
+  if block.blockFadeOut:IsPlaying() then return end
+
   block.blockFadeOut:SetScript('OnFinished', nil)
   block.blockFadeOut:SetScript('OnFinished', function(anim)
     --@debug@
     fprint(anim:GetName(), '|cFFFFFF00FINISHED|r', debugstack())--@end-debug@
     anim:SetScript('OnFinished', blockFadeOut_OnFinished)
     self:FreeBlock(block)
-    block.isAnimating = nil
   end)
   block.blockFadeOut:Play()
 end