Gladius Addon causing error message after arena game

Ever since 8.1, whenever I leave an arena game and load back into the world I get an error message that pops up caused by LUA 421 gladius attempt to index field. The addon works fine in arena most of the time but sometimes it happens in game as well. No one else seems to be having this issue as far as I’m aware. Could anyone give any advice please to fixing it. I have deleted the addon and reloaded it multiple times and tried on multiple toons. I’m not sure what to do.

Post the full error

1 Like

Message: Interface\AddOns\Gladius\Gladius.lua:421: attempt to index field ‘?’ (a nil value)
Time: Sun Dec 23 14:17:05 2018
Count: 6
Stack: Interface\AddOns\Gladius\Gladius.lua:421: attempt to index field ‘?’ (a nil value)
Interface\AddOns\Gladius\Gladius.lua:421: in function `?’
Interface\AddOns\Gladius\Gladius.lua:46: in function <Interface\AddOns\Gladius\Gladius.lua:38>

Locals: self =

{
GetColorOption = defined @Interface\AddOns\Gladius\Options.lua:149
defaults =
{
}
testCount = 0
instanceType = “arena”
OnInitialize = defined @Interface\AddOns\Gladius\Gladius.lua:220
NewModule = defined @Interface\AddOns\Gladius\Gladius.lua:95
EnableModule = defined @Interface\AddOns\Gladius\Gladius.lua:191
modules =
{
}
GetModule = defined @Interface\AddOns\Gladius\Gladius.lua:205
ARENA_PREP_OPPONENT_SPECIALIZATIONS = defined @Interface\AddOns\Gladius\Gladius.lua:442
UpdateColors = defined @Interface\AddOns\Gladius\Gladius.lua:482
CreateButton = defined @Interface\AddOns\Gladius\Gladius.lua:772
anchor = GladiusButtonAnchor {
}
UNIT_NAME_UPDATE = defined @Interface\AddOns\Gladius\Gladius.lua:397
UpdateFrame = defined @Interface\AddOns\Gladius\Gladius.lua:463
OnProfileChanged = defined @Interface\AddOns\Gladius\Gladius.lua:320
eventHandler = {
}
background = GladiusButtonBackground {
}
buttons =
{
}
UNIT_HEALTH = defined @Interface\AddOns\Gladius\Gladius.lua:861
GetUnitFrame = defined @Interface\AddOns\Gladius\Gladius.lua:881
LSM =
{
}
test = false
UnregisterAllEvents = defined @Interface\AddOns\Gladius\Gladius.lua:91
SetTemplate = defined @Interface\AddOns\Gladius\Options.lua:54
DisableModule = defined @Interface\AddOns\Gladius\Gladius.lua:198
SetupModule = defined @Interface\AddOns\Gladius\Options.lua:199
UpdateUnit = defined @Interface\AddOns\Gladius\Gladius.lua:505
UNIT_AURA = defined @Interface\AddOns\Gladius\Gladius.lua:845
ResetUnit = defined @Interface\AddOns\Gladius\Gladius.lua:740
SetupOptions = defined @Interface\AddOns\Gladius\Options.lua:252
GetPositions = defined @Interface\AddOns\Gladius\Options.lua:188
Print = defined @Interface\AddOns\Gladius\Gladius.lua:71
IsUnitShown = defined @Interface\AddOns\Gladius\Gladius.lua:877
Call = defined @Interface\AddOns\Gladius\Gladius.lua:56
JoinedArena = defined @Interface\AddOns\Gladius\Gladius.lua:340
SetColorOption = defined @Interface\AddOns\Gladius\Options.lua:154
L =
{
}
db =
{
}
SendMessage = defined @Interface\AddOns\Gladius\Gladius.lua:75
ARENA_OPPONENT_UPDATE = defined @Interface\AddOns\Gladius\Gladius.lua:409
testing =
{
}
OnDisable = defined @Interface\AddOns\Gladius\Gladius.lua:311
UNIT_SPELLCAST_START = defined @Interface\AddOns\Gladius\Gladius.lua:853
Debug = defined @Interface\AddOns\Gladius\Gladius.lua:67
ZONE_CHANGED_NEW_AREA = defined @Interface\AddOns\Gladius\Gladius.lua:329
RegisterEvent = defined @Interface\AddOns\Gladius\Gladius.lua:81
dbi =
{
}
UpdateAlpha = defined @Interface\AddOns\Gladius\Gladius.lua:764
ShowUnit = defined @Interface\AddOns\Gladius\Gladius.lua:671
TestUnit = defined @Interface\AddOns\Gladius\Gladius.lua:722
OnEnable = defined @Interface\AddOns\Gladius\Gladius.lua:280
IsValidUnit = defined @Interface\AddOns\Gladius\Gladius.lua:885
HideFrame = defined @Interface\AddOns\Gladius\Gladius.lua:486
GetModules = defined @Interface\AddOns\Gladius\Gladius.lua:209
LeftArena = defined @Interface\AddOns\Gladius\Gladius.lua:381
UnregisterEvent = defin

Gladius only creates the unit button if you are in an arena. The lines 2-4 of the CreateButton function is

	if instanceType ~= "arena" and not Gladius.test then
		return
	end

There is no check in the calling function to see if the button has actually been created so it goes on to try and access that unit button which doesn’t exist in the buttons table (error).

It appears the event “ARENA_PREP_OPPONENT_SPECIALIZATIONS” is being fired when not in an arena which is the base cause of the function calls that are causing the error.

Is there a way to fix this then? I’m having the same error as the OP, and it’s kinda driving me bonkers. Also, sorry for the super late reply.

I don’t know enough about Gladuis to know what the “right” course of action, nor do I know enough about why Blizzard introduced the extra event fire (delierate and desirable or bug that may be reversed at some stage).

With that in mind there a two possible, no guarantee, “quick” fixes you might try.

  1. Check the CreateButton function actually did create a frame before continuing on change lines 413 to 415 of Gladius.lua from:

     if not self.buttons[unit] then
     	self:CreateButton(unit)
     end
    

to read:

if not self.buttons[unit] then
	self:CreateButton(unit)
	if not self.buttons[unit] then return end
end

The problem with this is that the call to self:CreateButton(unit) also occures in other places so this might just move the error if other events have also been changed.

  1. If the new event is desireable AND Gladius should follow along with it (due to the if instanceType ... check my guess is this is not the best fix) then allow for button creation out of arenas change lines 777-780 of Gladius.lua from:

     local _, instanceType = IsInInstance()
     if instanceType ~= "arena" and not Gladius.test then
     	return
     end
    

to read:

--local _, instanceType = IsInInstance()
--if instanceType ~= "arena" and not Gladius.test then
--	return
--end

Ultimately it would be best if the author made the “real” fix.