Skip to content

CT Barmod generating LUA error with restricted frames #216

@kinghq1

Description

@kinghq1

This has been happening for some time, months. so I cannot say when xPack caused it. We all know how well Blizzard loves to break addons. Out of all my addons, CT Mod is the one I have used for years. Please fix :-(

10x CT_BarMod/CT_BarMod_Groups.lua:342: attempt to index global 'MainMenuBar' (a nil value)
[Blizzard_FrameXML/RestrictedFrames.lua]:670: in function <Blizzard_FrameXML/RestrictedFrames.lua:668>
[C]: ?
[C]: ?
[Blizzard_FrameXML/RestrictedFrames.lua]:674: in function <Blizzard_FrameXML/RestrictedFrames.lua:673>
[Blizzard_FrameXML/RestrictedFrames.lua]:812: in function 'CallMethod'
[ -- Secure code to set the action page.
-- Parameters: self, pagenum
-- self == group frame
-- select(1, ...) == action bar page number (1 to n).

local secureFrame = self:GetFrameRef("SecureFrame");
local hasVehicleUI = secureFrame:GetAttribute("hasVehicleUI");
local hasOverrideBar = secureFrame:GetAttribute("hasOverrideBar");
local hasPossessBar = secureFrame:GetAttribute("hasPossessBar");
local hasDragonRiding = secureFrame:GetAttribute("hasDragonRiding");
local showCancel = secureFrame:GetAttribute("showcancel");
local maxPage = secureFrame:GetAttribute("maxPage");

local page = select(1, ...);
page = floor(tonumber(page) or 1);
-- Use current page if out of range
if (page < 1 or page > maxPage) then
	page = secureFrame:GetAttribute("currentpage") or 1;
	if (page < 1 or page > maxPage) then
		page = 1;
	end
end
local usePage = page;
local base = (usePage - 1) * 12;
	
local count = 1;
local actionId;
local actionMode;
local button = self:GetFrameRef("child1");

-- see CT_BarMod_SpellFlyout.lua
local flyout = button:GetFrameRef("ctSpellFlyout")
if flyout then
	flyout:Hide()
end

while (button) do
	-- Determine the action number for this button.
	actionId = base + count;
	
	-- Determine the action mode value for this button.
	--
	-- "action" == action, multicast, tempshapeshift button
	-- "vehicle" == vehicle button
	-- "possess" == possess button
	-- "override" == override button
	-- "cancel" == cancel button
	-- "leave" == leave vehicle button
	--
	-- Page 1 to 10 == action
	-- Page 11 == multicast (GetMultiCastBarIndex() == 11)
	-- Page 12 == vehicle [vehicleui] and possess [possessbar] (GetVehicleBarIndex() == 12)
	-- Page 13 == temporary shapeshift (when does game use this?) (GetTempShapeshiftBarIndex() == 13)
	-- Page 14 == override [overridebar] (GetOverrideBarIndex() == 14)
	
	-- DRAGONFLIGHT
	-- Page 13 == Dragonriding
	-- Page 18 == override [overridebar]  (GetOverrideBarIndex() == 18)
	--
	if (usePage >= 12) then  -- vehicle or possess buttons
		if (hasVehicleUI) then
			if (count == 12) then  -- last button on bar
				actionMode = "leave";
			else
				actionMode = "vehicle";
			end
		elseif (hasPossessBar) then
			if (count == 11) then  -- second to last button on bar

-- actionMode = "cancel";
actionMode = "possess";
else
actionMode = "possess";
end
elseif (hasOverrideBar) then
if (count == 11) then -- second to last button on bar
-- actionMode = "cancel";
actionMode = "override";
else
actionMode = "override";
end
elseif hasDragonRiding then
actionMode = "action";
else -- unexpected set of buttons
actionMode = "action";
end
else
-- action buttons (pages 1 to 10)
-- multicast buttons (page 11)
-- tempshapeshift buttons (page 13)
actionMode = "action";
end
button:SetAttribute("actionMode", actionMode);
button:SetAttribute("action", actionId);

	--
	-- For similar "type" attribute code see also:
	-- 1) setActionPage_Secure in CT_BarMod_Use.lua
	-- 2) secureFrame_OnAttributeChanged in CT_BarMod.lua
	-- 3) initUpdateButtonType() in CT_BarMod.lua
	--
	if (actionMode == "cancel") then
		-- Set the "type" attribute based on whether or not the
		-- cancel possess button is enabled. That button when clicked
		-- can either exit a vehicle or cancel a possession spell.
		--
		-- We're using secure wrapper around Blizzard's PossessButton2's
		-- OnShow and OnHide scripts to tell us when the possess information
		-- is available and the possess button can be clicked. This is
		-- necessary because GetPossessInfo() is not callable from
		-- secure snippets.
		--
		if (showCancel) then
			button:SetAttribute("type", "click");
		else
			-- This is to prevent Blizzard's code from trying to cancel
			-- a nil buff thus causing an error if the user clicks the
			-- button when there is no possess info available.
			button:SetAttribute("type", nil);
		end

		-- We can't use a secure frame reference to a button since the
		-- frame reference does not have a "Click" method that the
		-- SecureTemplates.lua routine wants to use when our action button
		-- gets clicked.
		-- The button needs to be assigned to the attribute while in unsecure
		-- code (see CT_BarModUse.lua useButton:constructor()).
		--button:SetAttribute("clickbutton", button:GetFrameRef("PossessButton2"));

	elseif (actionMode == "leave") then
		button:SetAttribute("type", "click");

		-- We can't use a secure frame reference to a button since the
		-- frame reference does not have a "Click" method that the
		-- SecureTemplates.lua routine wants to use when our action button
		-- gets clicked.
		-- The button needs to be assigned to the attribute while in unsecure
		-- code (see CT_BarModUse.lua useButton:constructor()).
		--button:SetAttribute("clickbutton", button:GetFrameRef("VehicleMenuBarLeaveButton"));
	else
		if (button:GetAttribute("type") ~= "action") then
			button:SetAttribute("type", "action");
		end
	end

	do
		-- We need to update the show/hide state of the button when the page changes.
		-- If a user has the "hide empty button grid" option enabled, and they have an
		-- empty button on page 2, and they switch to page 1 while in combat, then the
		-- unsecure code can't unhide the button that was hidden while page 2 was
		-- displayed on the bar, so have to do it here in secure code.

		local show;

		-- If we are showing this button (ie. it is not being forced hidden)...
		if (button:GetAttribute("showbutton")) then

			-- If a show grid event is not currently active...
			if (button:GetAttribute("gridevent") == 0) then

				-- If the button has an action...
				if ( HasAction(actionId) ) then
					show = true;
				elseif ( actionMode == "cancel" ) then
					show = true;
				elseif ( actionMode == "leave" ) then
					show = true;
				else
					-- The button has no action.
					-- If we want to show empty buttons...
					if (button:GetAttribute("gridshow") > 0) then
						show = true;
					end
				end
			else
				-- There is a show grid event that is currently active.
				-- The user is probably dragging an action button.
				-- Show all buttons, empty or not.
				show = true;
			end
		end

		if (show) then
			button:Show();
		else
			button:Hide();
		end
	end

	count = count + 1;
	button = self:GetFrameRef("child" .. count);
end

self:SetAttribute("currentpage", usePage);

-- Perform visual updates of the buttons
self:CallMethod("setActionPage", usePage);

]:196: in function <[string " -- Secure code to set the action page...."]:1>
[tail call]: ?
[C]: ?
[Blizzard_FrameXML/RestrictedExecution.lua]:483: in function <...aceBlizzard_FrameXML/RestrictedExecution.lua:446>
[Blizzard_FrameXML/RestrictedFrames.lua]:739: in function 'RunAttribute'
[ -- Parameters: self, name, value
if (name == "state-barpage") then
-- value == action page number

	-- Bar state
	self:RunAttribute("setActionPage", value);
end

]:6: in function <[string " -- Parameters: self, name, value..."]:1>
[tail call]: ?
...[Blizzard_FrameXML/SecureStateDriver.lua]:164: in function <...rfaceBlizzard_FrameXML/SecureStateDriver.lua:146>
[C]: in function 'SetAttribute'
[Blizzard_FrameXML/SecureStateDriver.lua]:11: in function <...rfaceBlizzard_FrameXML/SecureStateDriver.lua:8>
[tail call]: ?
[CT_BarMod/CT_BarMod_Groups.lua]:2017: in function 'registerPagingStateDriver'
[CT_BarMod/CT_BarMod_Use.lua]:1771: in function 'setupPresetGroups'
[CT_BarMod/CT_BarMod.lua]:783: in function <CT_BarMod/CT_BarMod.lua:740>
[tail call]: ?
[CT_Library/CT_Library.lua]:901: in function 'value'
[CT_Library/CT_Library.lua]:691: in function <CT_Library/CT_Library.lua:687>

Locals:
message = "CT_BarMod/CT_BarMod_Groups.lua:342: attempt to index global 'MainMenuBar' (a nil value)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions