1
1
local MAJOR_VERSION = " LibGetFrame-1.0"
2
- local MINOR_VERSION = 3
2
+ local MINOR_VERSION = 4
3
3
if not LibStub then error (MAJOR_VERSION .. " requires LibStub." ) end
4
4
local lib , oldversion = LibStub :NewLibrary (MAJOR_VERSION , MINOR_VERSION )
5
5
if not lib then return end
6
6
7
+ local InCombatLockdown , UnitIsUnit , tinsert = InCombatLockdown , UnitIsUnit , tinsert
8
+
7
9
local maxDepth = 50
8
10
9
11
local defaultFramePriorities = {
@@ -60,13 +62,15 @@ local defaultTargettargetFrames = {
60
62
}
61
63
62
64
local GetFramesCache = {}
65
+ local GetFramesCacheLockdown = {}
63
66
64
67
local GetFramesCacheListener = CreateFrame (" Frame" )
65
68
GetFramesCacheListener :RegisterEvent (" PLAYER_REGEN_DISABLED" )
66
69
GetFramesCacheListener :RegisterEvent (" PLAYER_REGEN_ENABLED" )
67
70
GetFramesCacheListener :RegisterEvent (" GROUP_ROSTER_UPDATE" )
68
71
GetFramesCacheListener :SetScript (" OnEvent" , function (self , event , ...)
69
72
GetFramesCache = {}
73
+ GetFramesCacheLockdown = {}
70
74
end )
71
75
72
76
local function FindButtonsForUnit (frame , target , depth )
@@ -94,6 +98,9 @@ local function FindButtonsForUnit(frame, target, depth)
94
98
end
95
99
96
100
local function GetFrames (target , ignoredFrames )
101
+ if GetFramesCacheLockdown [target ] then
102
+ return {}
103
+ end
97
104
if not UnitExists (target ) then
98
105
if type (target ) == " string" and target :find (" Player" ) then
99
106
target = select (6 ,GetPlayerInfoByGUID (target ))
@@ -120,6 +127,11 @@ local function GetFrames(target, ignoredFrames)
120
127
121
128
frames = # frames > 0 and frames or FindButtonsForUnit (UIParent , target , 0 )
122
129
130
+ -- if we are in combat and no frame was found we want to blacklist unit until cache is wiped
131
+ if # frames == 0 and InCombatLockdown () then
132
+ GetFramesCacheLockdown [target ] = true
133
+ end
134
+
123
135
-- filter ignored frames
124
136
for k , frame in pairs (frames ) do
125
137
local name = frame :GetName ()
0 commit comments