From 144060e9d3b8399c80accc38e5d06cf5efecb6e1 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Tue, 25 Aug 2026 09:59:07 +0200 Subject: [PATCH] Revert target-of-target handler hook after crashes --- mods/unitframes-classportrait.lua | 45 +++++++++++-------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/mods/unitframes-classportrait.lua b/mods/unitframes-classportrait.lua index 91a12dd..c2ae453 100644 --- a/mods/unitframes-classportrait.lua +++ b/mods/unitframes-classportrait.lua @@ -75,36 +75,21 @@ module.enable = function(self) UpdatePortraits(PartyMemberFrame4) end) - -- Turtle/Vanilla already runs TargetofTarget_OnUpdate for the target-of-target - -- frame. Reuse that existing update path instead of adding a second poller. - -- Keep a GUID cache when ClassicAPI is available so two units with the same - -- display name are still detected as different units. - local lasttotguid = nil - if type(TargetofTarget_OnUpdate) == "function" then - local originalTargetofTargetOnUpdate = TargetofTarget_OnUpdate - TargetofTarget_OnUpdate = function(elapsed) - originalTargetofTargetOnUpdate(elapsed) + -- Target-of-target has no reliable vanilla portrait event. The old module + -- refreshed it every rendered frame. ClassicAPI gives us UnitGUID, so poll + -- cheaply at 5 Hz and only redraw when the actual unit changes. + local tot = CreateFrame("Frame", nil, TargetFrame) + tot.elapsed = 0 + tot.lastguid = nil + tot:SetScript("OnUpdate", function() + this.elapsed = this.elapsed + arg1 + if this.elapsed < .2 then return end + this.elapsed = 0 - local guid = API.UnitGUID and API.UnitGUID("targettarget") or UnitName("targettarget") - if guid ~= lasttotguid then - lasttotguid = guid - UpdatePortraits(TargetofTargetFrame) - end + local guid = API.UnitGUID and API.UnitGUID("targettarget") or UnitName("targettarget") + if guid ~= this.lastguid then + this.lastguid = guid + UpdatePortraits(TargetofTargetFrame) end - else - -- Compatibility fallback for clients that do not expose the stock handler. - local tot = CreateFrame("Frame", nil, TargetFrame) - tot.elapsed = 0 - tot:SetScript("OnUpdate", function() - this.elapsed = this.elapsed + arg1 - if this.elapsed < .2 then return end - this.elapsed = 0 - - local guid = API.UnitGUID and API.UnitGUID("targettarget") or UnitName("targettarget") - if guid ~= lasttotguid then - lasttotguid = guid - UpdatePortraits(TargetofTargetFrame) - end - end) - end + end) end