LUA Error, ALT + Mouseover "processable" Item in Chat -> attempt to call method 'GetID' (a nil value)
fubaWoW opened this issue ยท 2 comments
Describe the bug
See Title
How to reproduce
ALT + Mouseover "processable" Item in Chat
Lua Error
6x Molinari/Molinari.lua:118: attempt to call method 'GetID' (a nil value)
[string "@Molinari/Molinari.lua"]:118: in function `GetBagAndSlotID'
[string "@Molinari/Molinari.lua"]:23: in function `ApplySpell'
[string "@Molinari/Molinari.lua"]:277: in function <Molinari/Molinari.lua:242>
[string "@Molinari/Molinari.lua"]:303: in function <Molinari/Molinari.lua:295>
[string "=(tail call)"]: ?
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:60: in function <SharedXML/Tooltip/TooltipDataHandler.lua:55>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:80: in function <SharedXML/Tooltip/TooltipDataHandler.lua:76>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:116: in function <SharedXML/Tooltip/TooltipDataHandler.lua:106>
[string "=[C]"]: in function `SetAttribute'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:141: in function <SharedXML/Tooltip/TooltipDataHandler.lua:134>
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:282: in function <SharedXML/Tooltip/TooltipDataHandler.lua:240>
[string "=[C]"]: in function `securecallfunction'
[string "@SharedXML/Tooltip/TooltipDataHandler.lua"]:237: in function <SharedXML/Tooltip/TooltipDataHandler.lua:236>
[string "=(tail call)"]: ?
[string "@TradeSkillMaster/LibTSM/Service/ItemTooltipClasses/Wrapper.lua"]:111: in function <...Master/LibTSM/Service/ItemTooltipClasses/Wrapper.lua:109>
[string "=[C]"]: in function `SetHyperlink'
[string "@ElvUI/Core/Modules/Chat/Chat.lua"]:1528: in function `?'
[string "@Ace3/AceHook-3.0-9/AceHook-3.0.lua"]:90: in function <Ace3/AceHook-3.0/AceHook-3.0.lua:87>
Locals:
self = Molinari {
CalculateAction = <function> defined @FrameXML/SecureTemplates.lua:609
ApplyTradeSkill = <function> defined @Molinari/Molinari.lua:74
0 = <userdata>
ApplySpell = <function> defined @Molinari/Molinari.lua:22
RegisterEvent = <function> defined @Molinari/mixins/event.lua:7
IsEventRegistered = <function> defined @Molinari/mixins/event.lua:39
GetModifier = <function> defined @Molinari/Molinari.lua:139
UpdateStateDriver = <function> defined @Molinari/Molinari.lua:204
SetGlowColor = <function> defined @Molinari/Molinari.lua:131
Attach = <function> defined @Molinari/Molinari.lua:126
GetBagAndSlotID = <function> defined @Molinari/Molinari.lua:101
ApplyItem = <function> defined @Molinari/Molinari.lua:47
GetGlowColor = <function> defined @Molinari/Molinari.lua:135
sparkles = <table> {
}
UnregisterEvent = <function> defined @Molinari/mixins/event.lua:22
GetModifierCondition = <function> defined @Molinari/Molinari.lua:151
}
parent = FontString {
0 = <userdata>
messageInfo = <table> {
}
}
bagID = 0
slotID = nil
(*temporary) = nil
(*temporary) = FontString {
0 = <userdata>
messageInfo = <table> {
}
}
(*temporary) = "attempt to call method 'GetID' (a nil value)"
Are you using an addon that enables mouseover on item links in chat? I can't replicate this at all.
Yes, i use ElvUI and it it's default there.
but i found the error, you just miss some checks in the function Molinari:GetBagAndSlotID()
Original function:
function Molinari:GetBagAndSlotID()
local parent = GetMouseFocus()
if not parent then
return
end
local bagID, slotID
if parent.GetSlotAndBagID then
-- this is the preferred API to use, added in Dragonflight, as it's 100% accurate
slotID, bagID = parent:GetSlotAndBagID()
elseif parent.GetBagID then
-- the above is preferred
bagID = parent:GetBagID()
slotID = parent:GetID()
elseif parent:GetParent() then
-- this is a complete guesswork, bag addons should implement one of the two above APIs
bagID = parent:GetParent():GetID()
slotID = parent:GetID()
end
if bagID and bagID >= 0 and slotID and slotID >= 0 then
return bagID, slotID
end
end
fixed function:
function Molinari:GetBagAndSlotID()
local parent = GetMouseFocus()
if not parent then
return
end
local bagID, slotID
if parent.GetSlotAndBagID then
-- this is the preferred API to use, added in Dragonflight, as it's 100% accurate
slotID, bagID = parent:GetSlotAndBagID()
elseif parent.GetBagID and parent.GetID then
-- the above is preferred
bagID = parent:GetBagID()
slotID = parent:GetID()
elseif parent:GetParent() and (parent:GetParent().GetID) and (parent.GetID) then
-- this is a complete guesswork, bag addons should implement one of the two above APIs
bagID = parent:GetParent():GetID()
slotID = parent:GetID()
end
if bagID and bagID >= 0 and slotID and slotID >= 0 then
return bagID, slotID
end
end
Best way is to check a if a Frame or Table really have the function before try to call it.
In this case if there is no parent.GetID
, with the fixed function this can never happen again!
But also with parent:GetParent().GetID
it is very likely to get a wrong parent
if any foreign AddOn hooks the "right" frame.