From 3e96e6fe33cd3c5ec141492a5299a2f9b3135908 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sun, 13 Jul 2014 21:25:28 -0400 Subject: [PATCH] Follow Model-View-Controller better to avoid infinite loops. This avoids UpdateIcons() calling EvaluateScript() which may call UpdateIcons() again. --- OvaleCompile.lua | 10 +++------- OvaleFrame.lua | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 27693c6..3ada701 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -426,10 +426,10 @@ function OvaleCompile:CompileScript(event) self:EventHandler(event) end -function OvaleCompile:EvaluateScript() +function OvaleCompile:EvaluateScript(forceEvaluation) profiler.Start("OvaleCompile_EvaluateScript") self_canEvaluate = self_canEvaluate or Ovale:IsPreloaded(self_requirePreload) - if self_canEvaluate and self.ast then + if self_canEvaluate and self.ast and (forceEvaluation or not self.serial or self.serial < self_serial) then Ovale:DebugPrint(OVALE_COMPILE_DEBUG, "Evaluating script.") -- Reset compilation state. local ok = true @@ -438,6 +438,7 @@ function OvaleCompile:EvaluateScript() wipe(self_icon) OvaleCooldown:ResetSharedCooldowns() self_timesEvaluated = self_timesEvaluated + 1 + self.serial = self_serial -- Evaluate every declaration node of the script. for _, node in ipairs(self.ast.child) do @@ -481,11 +482,6 @@ function OvaleCompile:GetFunctionNode(name) end function OvaleCompile:GetIconNodes() - -- Evaluate the script if it is outdated. - if not self.serial or self.serial < self_serial then - self.serial = self_serial - self:EvaluateScript() - end return self_icon end diff --git a/OvaleFrame.lua b/OvaleFrame.lua index 1fbd443..f49dc05 100644 --- a/OvaleFrame.lua +++ b/OvaleFrame.lua @@ -171,6 +171,7 @@ do local refresh = forceRefresh or next(Ovale.refreshNeeded) if not refresh then return end + OvaleCompile:EvaluateScript() local iconNodes = OvaleCompile:GetIconNodes() if not iconNodes then return end -- 1.7.9.5