One-shot event handlers: use EventUtil.RegisterOnceFrameEventAndCallback instead of self-unregistering frames

This commit is contained in:
Brues
2026-11-03 01:07:02 -06:00
parent d143e91f81
commit 70bfc1c443
7 changed files with 10 additions and 59 deletions
+1 -5
View File
@@ -1,7 +1,5 @@
pfUI:RegisterModule("chatcopy", function ()
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function()
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
if not pfUI.chat then return end
local button = CreateFrame("Button", "pfChatCopyButton", pfUI.chat.left.panelTop)
@@ -99,7 +97,5 @@ pfUI:RegisterModule("chatcopy", function ()
frame.scroll = scroll
end
this:UnregisterAllEvents()
end)
end)
+1 -5
View File
@@ -801,11 +801,7 @@ pfUI:RegisterModule("thirdparty-vanilla", function()
HookAddon("SortBags", function()
if C.thirdparty.sortbags.enable == "0" then return end
local sort = CreateFrame("Frame", nil)
sort:RegisterEvent("PLAYER_ENTERING_WORLD")
sort:SetScript("OnEvent", function()
this:UnregisterAllEvents()
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
pfUI.thirdparty.RegisterBagSort("SortBags",
function()
SortBags()
+1 -5
View File
@@ -142,11 +142,7 @@ pfUI:RegisterModule("thirdparty", function()
HookAddon("MrPlow", function()
if C.thirdparty.mrplow.enable == "0" then return end
local sort = CreateFrame("Frame", nil)
sort:RegisterEvent("PLAYER_ENTERING_WORLD")
sort:SetScript("OnEvent", function()
this:UnregisterAllEvents()
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
local MrPlowL = AceLibrary and AceLibrary("AceLocale-2.2"):new("MrPlow")
if not (MrPlowL and MrPlowL["Bank"]) then return end
+1 -27
View File
@@ -180,33 +180,7 @@ pfUI:RegisterModule("unitxp", function ()
CreateTargetIndicators()
-- Also try on PLAYER_ENTERING_WORLD in case target frame wasn't ready
local initFrame = CreateFrame("Frame")
initFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
initFrame:RegisterEvent("PLAYER_LOGOUT")
initFrame:SetScript("OnEvent", function()
-- Handle shutdown to prevent crash 132
if event == "PLAYER_LOGOUT" then
this:UnregisterAllEvents()
this:SetScript("OnEvent", nil)
-- Stop indicator OnUpdate scripts
if pfUI.uf and pfUI.uf.target then
if pfUI.uf.target.behindIndicator then
pfUI.uf.target.behindIndicator:SetScript("OnUpdate", nil)
end
if pfUI.uf.target.distanceIndicator then
pfUI.uf.target.distanceIndicator:SetScript("OnUpdate", nil)
end
-- free-frame mode polls from its own scanner frame, not the indicator
if pfUI.uf.target.distanceScanner then
pfUI.uf.target.distanceScanner:SetScript("OnUpdate", nil)
end
end
return
end
CreateTargetIndicators()
this:UnregisterAllEvents()
end)
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", CreateTargetIndicators)
-- OS Notification Support
if C.unitframes.unitxp_notify == "1" then