Skip to content

Commit ced13f9

Browse files
committed
don't delay ScanFrames on init fixes #7
1 parent abdfb24 commit ced13f9

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

LibGetFrame-1.0.lua

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local MAJOR_VERSION = "LibGetFrame-1.0"
2-
local MINOR_VERSION = 7
2+
local MINOR_VERSION = 8
33
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
44
local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
55
if not lib then return end
@@ -86,11 +86,16 @@ local function ScanFrames(depth, frame, ...)
8686
ScanFrames(depth, ...)
8787
end
8888

89-
local function ScanForUnitFrames()
90-
C_Timer.After(1, function()
89+
local function ScanForUnitFrames(noDelay)
90+
if noDelay then
9191
wipe(GetFramesCache)
9292
ScanFrames(0, UIParent)
93-
end)
93+
else
94+
C_Timer.After(1, function()
95+
wipe(GetFramesCache)
96+
ScanFrames(0, UIParent)
97+
end)
98+
end
9499
end
95100

96101
local function isFrameFiltered(name, ignoredFrames)
@@ -150,19 +155,19 @@ local defaultOptions = {
150155
}
151156

152157
local GetFramesCacheListener
153-
lib.Init = function()
158+
lib.Init = function(noDelay)
154159
GetFramesCacheListener = CreateFrame("Frame")
155160
GetFramesCacheListener:RegisterEvent("PLAYER_REGEN_DISABLED")
156161
GetFramesCacheListener:RegisterEvent("PLAYER_REGEN_ENABLED")
157162
GetFramesCacheListener:RegisterEvent("PLAYER_ENTERING_WORLD")
158163
GetFramesCacheListener:RegisterEvent("GROUP_ROSTER_UPDATE")
159164
GetFramesCacheListener:SetScript("OnEvent", ScanForUnitFrames)
160165

161-
ScanForUnitFrames()
166+
ScanForUnitFrames(noDelay)
162167
end
163168

164169
function lib.GetUnitFrame(target, opt)
165-
if not GetFramesCacheListener then lib.Init() end
170+
if not GetFramesCacheListener then lib.Init(true) end
166171
opt = opt or {}
167172
setmetatable(opt, { __index = defaultOptions })
168173

0 commit comments

Comments
 (0)