diff --git a/Extensions/Mouseover/Dragonflight3.lua b/Extensions/Mouseover/Dragonflight3.lua index dbe7b3c..fab9334 100644 --- a/Extensions/Mouseover/Dragonflight3.lua +++ b/Extensions/Mouseover/Dragonflight3.lua @@ -14,9 +14,6 @@ Extension.RegisterEvent("PLAYER_ENTERING_WORLD", "DelayedInit") local hookedFrames = {} --- Re-entrancy guard to prevent stack overflow -local isProcessing = false - function Extension.HookFrame(frame, unit) if not frame or hookedFrames[frame] then return end @@ -24,23 +21,15 @@ function Extension.HookFrame(frame, unit) local onLeave = frame:GetScript("OnLeave") frame:SetScript("OnEnter", function() - if not isProcessing then - local u = unit or this.unit - if u then - isProcessing = true - CleveRoids.SetMouseoverFrom("df3", u) - isProcessing = false - end + local u = unit or this.unit + if u then + CleveRoids.SetMouseoverFrom("df3", u) end if onEnter then onEnter() end end) frame:SetScript("OnLeave", function() - if not isProcessing then - isProcessing = true - CleveRoids.ClearMouseoverFrom("df3") - isProcessing = false - end + CleveRoids.ClearMouseoverFrom("df3") if onLeave then onLeave() end end) diff --git a/Extensions/Mouseover/DragonflightReloaded.lua b/Extensions/Mouseover/DragonflightReloaded.lua index 57c43d6..ceaa0fc 100644 --- a/Extensions/Mouseover/DragonflightReloaded.lua +++ b/Extensions/Mouseover/DragonflightReloaded.lua @@ -13,9 +13,6 @@ Extension.RegisterEvent("PLAYER_ENTERING_WORLD", "DelayedInit") local hookedFrames = {} --- Re-entrancy guard to prevent stack overflow -local isProcessing = false - function Extension.HookFrame(frame, unit) if not frame or hookedFrames[frame] then return end @@ -23,23 +20,15 @@ function Extension.HookFrame(frame, unit) local onLeave = frame:GetScript("OnLeave") frame:SetScript("OnEnter", function() - if not isProcessing then - local u = unit or this.unit - if u then - isProcessing = true - CleveRoids.SetMouseoverFrom("dfr", u) - isProcessing = false - end + local u = unit or this.unit + if u then + CleveRoids.SetMouseoverFrom("dfr", u) end if onEnter then onEnter() end end) frame:SetScript("OnLeave", function() - if not isProcessing then - isProcessing = true - CleveRoids.ClearMouseoverFrom("dfr") - isProcessing = false - end + CleveRoids.ClearMouseoverFrom("dfr") if onLeave then onLeave() end end) diff --git a/Extensions/Mouseover/LunaUnitFrames.lua b/Extensions/Mouseover/LunaUnitFrames.lua index bcadf5e..0172355 100644 --- a/Extensions/Mouseover/LunaUnitFrames.lua +++ b/Extensions/Mouseover/LunaUnitFrames.lua @@ -17,9 +17,6 @@ Extension.RegisterEvent("PLAYER_ENTERING_WORLD", "DelayedInit") -- Track which frames we've hooked local hookedFrames = {} --- Re-entrancy guard to prevent stack overflow -local isProcessing = false - function Extension.HookFrame(frame) if not frame or hookedFrames[frame] then return end @@ -27,20 +24,14 @@ function Extension.HookFrame(frame) local onLeave = frame:GetScript("OnLeave") frame:SetScript("OnEnter", function() - if not isProcessing and this.unit then - isProcessing = true + if this.unit then CleveRoids.SetMouseoverFrom("luna", this.unit) - isProcessing = false end if onEnter then onEnter() end end) frame:SetScript("OnLeave", function() - if not isProcessing then - isProcessing = true - CleveRoids.ClearMouseoverFrom("luna") - isProcessing = false - end + CleveRoids.ClearMouseoverFrom("luna") if onLeave then onLeave() end end) diff --git a/Extensions/Mouseover/XPerl.lua b/Extensions/Mouseover/XPerl.lua index ec82acc..358817c 100644 --- a/Extensions/Mouseover/XPerl.lua +++ b/Extensions/Mouseover/XPerl.lua @@ -11,26 +11,18 @@ local CleveRoids = _G.CleveRoids or {} local Extension = CleveRoids.RegisterExtension("XPerl") Extension.RegisterEvent("ADDON_LOADED", "OnLoad") --- Re-entrancy guard to prevent stack overflow -local isProcessing = false - -- X-Perl uses XPerl_PlayerTip(unitid) for OnEnter and XPerl_PlayerTipHide() for OnLeave -- We hook these functions to track mouseover +-- Note: Re-entrancy is handled in Utility.lua's SetMouseoverFrom/ClearMouseoverFrom function Extension.OnEnter(unitid) - if isProcessing then return end if unitid and unitid ~= "" then - isProcessing = true CleveRoids.SetMouseoverFrom("xperl", unitid) - isProcessing = false end end function Extension.OnLeave() - if isProcessing then return end - isProcessing = true CleveRoids.ClearMouseoverFrom("xperl") - isProcessing = false end function Extension.OnLoad() diff --git a/Utility.lua b/Utility.lua index 6f8d5ad..518fea9 100644 --- a/Utility.lua +++ b/Utility.lua @@ -296,6 +296,9 @@ do return bestSource, bestUnit end + -- Re-entrancy guard to prevent stack overflow from UI update cascades + local isUpdatingMouseover = false + local function apply(unit) if CleveRoids.hasSuperwow and _G.SetMouseoverUnit then _G.SetMouseoverUnit(unit) @@ -306,17 +309,19 @@ do end function CleveRoids.SetMouseoverFrom(source, unit) - if not source then return end + if not source or isUpdatingMouseover then return end CleveRoids.__mo.sources[source] = unit local _, bestUnit = getBest() if bestUnit ~= CleveRoids.__mo.current then CleveRoids.__mo.current = bestUnit + isUpdatingMouseover = true apply(bestUnit) + isUpdatingMouseover = false end end function CleveRoids.ClearMouseoverFrom(source, unitIfMatch) - if not source then return end + if not source or isUpdatingMouseover then return end if unitIfMatch and CleveRoids.__mo.sources[source] ~= unitIfMatch then return end @@ -324,7 +329,9 @@ do local _, bestUnit = getBest() if bestUnit ~= CleveRoids.__mo.current then CleveRoids.__mo.current = bestUnit + isUpdatingMouseover = true apply(bestUnit) + isUpdatingMouseover = false end end end