Thread Tools Display Modes
03-27-10, 11:49 PM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Confusing error, need some help

Code:
Message: Interface\FrameXML\UIDropDownMenu.lua:227: attempt to index local 'listFrame' (a nil value)
Time: 03/28/10 00:13:09
Count: 1
Stack: Interface\FrameXML\UIDropDownMenu.lua:227: in function `UIDropDownMenu_AddButton'
Interface\AddOns\CFM\CFM_GUI.lua:1049: in function `initFunction'
Interface\FrameXML\UIDropDownMenu.lua:69: in function `UIDropDownMenu_Initialize'
Interface\AddOns\CFM\CFM_GUI.lua:811: in function `CFM_CreateProps'
Interface\AddOns\CFM\CFM_GUI.lua:96: in function `CFM_GUI'
Interface\AddOns\CFM\CFM.lua:16: in function `value'
Interface\FrameXML\ChatFrame.lua:3577: in function `ChatEdit_ParseText'
Interface\FrameXML\ChatFrame.lua:3222: in function `ChatEdit_SendText'
Interface\FrameXML\ChatFrame.lua:3246: in function `ChatEdit_OnEnterPressed'
[string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>

Locals: info = <table> {
 value = 0
 owner = UIParent {
 }
 func = <function> defined @Interface\AddOns\CFM\CFM_GUI.lua:1045
 text = "BACKGROUND"
}
level = 0
listFrame = nil
index = 1
width = nil
(*temporary) = <table> {
 ARKINV_SearchFrameViewTableRow12T1 = ARKINV_SearchFrameViewTableRow12T1 {
 }
 ContainerFrame5Item7 = ContainerFrame5Item7 {
 }
 MultiCastActionButton6Cooldown = MultiCastActionButton6Cooldown {
 }
 MerchantItem9ItemButtonStock = MerchantItem9ItemButtonStock {
 }
 GetTrainerServiceTypeFilter = <function> defined =[C]:-1
 UNIT_NAMES_COMBATLOG_TOOLTIP = "Color unit names."
 KBASE_NUM_FAKE_CATEGORIES = 1
 Recount_MainWindow_Bar6 = Recount_MainWindow_Bar6 {
 }
 SetTrainerServiceTypeFilter = <function> defined =[C]:-1
 MerchantItem6AltCurrencyFrameHonorTexture = MerchantItem6AltCurrencyFrameHonorTexture {
 }
 SmartBuffOptionsFrame_cbBuffS6 = SmartBuffOptionsFrame_cbBuffS6 {
 }
 TutorialFrameLeft19 = TutorialFrameLeft19 {
 }
 MultiCastActionButton2Cooldown = MultiCastActionButton2Cooldown {
 }
 ERR_TRADE_EQUIPPED_BAG = "You can't trade equipped bags."
 PVP_RANK_6_1 = "Corporal"
 MultiBarLeftButton7 = MultiBarLeftButton7 {
 }
 OPTION_TOOLTIP_SHOW_MULTIBAR4 = "Toggles an additional optional actionbar on the right side of the screen."
 InterfaceOptionsDisplayPanelShowAggroPercentageText = InterfaceOptionsDisplayPanelShowAggroPercentageText {
 }
 VideoOptionsFrameDefaults = VideoOptionsFrameDefaults {
 }
 MerchantItem4AltCurrencyFrameItem1Text = MerchantItem4AltCurrencyFrameItem1Text {
 }
 AMItmTblSrtBt11-6Text = AMItmTblSrtBt11-6Text {
 }
 BINDING_NAME_NAMEPLATES = "Show Enemy Name Plates"
 NxTeamHUD = NxTeamHUD {
 }
 MAIL_LETTER_TOOLTIP = "Click to make a permanent
copy of this letter."
 UnitFrameManaBar_UnregisterDefaultEvents = <function> defined @Interface\FrameXML\UnitFrame.lua:298
 ContainerFrame1Item22Cooldown = ContainerFrame1Item22Cooldown {
 }
 CHAT_CONFIG_OTHER_COMBAT = <table> {
 }
 BT4Button22Flash = BT4Button22Flash {
 }
 CONSOLIDATED_BUFFS_PER_ROW = 4
 TutorialFrameRight19 = TutorialFrameRight19 {
 }
 MoneyFrame_OnEvent = <function> defined @Interface\FrameXML\MoneyFrame.lua:184
 WatchFrameItem_OnEvent = <function> defined @Interface\FrameXML\WatchFrame.lua:1206
 InterfaceOptionsCombatTextPanelFCTDropDown_OnClick = <function> defined @Interface\FrameXML\InterfaceOptionsPanels.lua:1080
 TradeSkillInputBoxLeft = TradeSkillInputBoxLeft {
 }
 LFGTeleport = <function> defined =[C]:-1
 SpellButton6Cooldown = SpellButton6Cooldown {
 }
 ChannelMemberButton10Name = ChannelMemberButton10Name {
 }
 UIDROPDOWNMENU_OPEN_MENU = BtexSTRATADropDownMenuCUSTOM {
 }
 PetStableMoneyFrameGoldButtonText = PetStableMoneyFrameGoldButtonText {
 }
 GS_Length = 223
 VOICEMACRO_4_Sc_1_FEMALE = "Help me attack!"
 VideoOptionsPanel_Cancel = <function> defined @Interface\FrameXML\VideoOptionsPanels.lua:36
 PetPaperDollFrameTab3Right = PetPaperDollFrameTab3Right {
 }
 ChannelMemberButton10SpeakerFrameOn = ChannelMemberButton10SpeakerFrameOn {
 }
 EventTraceFrameTitleButton = EventTraceFrameTitleButton {
 }
 BINDING_NAME_RECOUNT_TOGGLE_MAIN = "Toggles the main window"
 SecureCmdItemParse = <function> defin
This didn't happen before I moved the GUI to it's own file.
  Reply With Quote
03-28-10, 05:29 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
I'm not a pro when it comes to "this" and "self" and never touched or
UIDropDown.
The use of "this" is the cause of your problem I would guess.
If I understand it right "this" has the value of the frame that got
the last event. Your log says the last event was from Chatframe.

Code:
function CFM_FromDropInit()
	level = level or 1
	local info = UIDropDownMenu_CreateInfo()
	info.text = "CENTER"
	info.value = 0
	info.func = function() CFM_FromBoxClick() end
	info.owner = this:GetParent()
	info.checked = nil
	info.icon = nil
	UIDropDownMenu_AddButton(info, level)
A problem that is worse is "level" is a global it seems to me when I look at the code
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
03-28-10, 07:09 AM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Don't think this is the issue. If it were, it wouldn't have worked before I put the GUI in a separate file. CFM_GUI being pulled out is the only change and for some reason has lead to this error. I'm assuming something was local in the main CFM.lua that is not being referenced now, but haven't the foggiest clue to what it is.
  Reply With Quote
03-28-10, 08:25 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Code:
function UIDropDownMenu_AddButton(info, level)
	--[[
	Might to uncomment this if there are performance issues 
	if ( not UIDROPDOWNMENU_OPEN_MENU ) then
		return;
	end
	]]
	if ( not level ) then
		level = 1;
	end
	
	local listFrame = _G["DropDownList"..level];
	local index = listFrame and (listFrame.numButtons + 1) or 1;
	local width;
When its not "this" then its "level" that is causing your problem.
Make it local and it should work.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
03-28-10, 12:30 PM   #5
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Can I have some context please? Like, the code which calls the function?
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
03-28-10, 01:00 PM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
I just rigged up a dropdown menu myself. Granted very simple so far but it is spread across 3 files.

1. The interface generic function file where the basics are definited
2. The addons interface specific file where the menu is created for the addon
3. The main addon file that creates the button that calls the menu

I haven't added a submenu yet so this code may not work for that scenario but here's what I managed to do for a single menu list.

This is the generic code fragments in file 1.
Code:
addonData["Interface"].OnShowMenu = function(self,dropDownLevel,dropDownValue,dropDownFrame,dropDownAnchor,xOffset,yOffset)
	ToggleDropDownMenu(dropDownLevel, dropDownValue, dropDownFrame, dropDownAnchor, xOffset, yOffset);
end

addonData["Interface"].OnInitMenu = function(self)
	UIDropDownMenu_Initialize(self, self.InitFunction, self.MenuType);	
end

addonData["Interface"].OnClick = function(self,button,down)
	-- Is this a drop down menu object ?
	if ( self.Menu  ) then
		addonData["Interface"].OnShowMenu(self,1,nil,self.Menu,self,0,0);
	end
end

addonData["Interface"].AddDropDownMenu = function(name,parent,initFunction,menuType)
	local f = CreateFrame("Button",name,parent,"UIDropDownMenuTemplate");
	if ( initFunction and menuType ) then
		f.InitFunction = initFunction;
		f.MenuType = menuType;
		addonData["Interface"].OnInitMenu(f);
	end
	return f;
end

addonData["Interface"].AddDropDownTooltip = function(info,tooltipTitle,tooltipText)
	local info = info;
	if ( tooltipTitle and tooltipText ) then
		info.tooltipTitle = tooltipTitle;
		info.tooltipText = tooltipText;
	end
	return info;
end

addonData["Interface"].AddDropDownClickableItem = function(name,parent,text,isDisabled,isCheckable,isChecked,funcCall,funcArg1,funcArg2, tooltipTitle,tooltipText)
	local info = UIDropDownMenu_CreateInfo();
	info.text = text;
	
	if ( isDisabled ~= nil ) then
		info.disabled = isDisabled;
	end
	
	if ( isCheckable and isChecked ) then
		info.notCheckable = not isCheckable; 
		info.checked = isChecked;
	end
	
	-- Deal with Function Calls ( funcCall(self,arg1,arg2,checked) )
	if ( funcCall ) then
		info.func = funcCall;
		-- Deal with Arguments
		if ( funcArg1 ) then 
			info.arg1 = funcArg1; 
			if ( funcArg2 ) then 
				info.arg2 = funcArg2; 
			end
		end
	end
	
	if ( tooltipTitle and tooltipText ) then
		info = addonData["Interface"].AddDropDownTooltip(info,tooltipTitle,tooltipText);
	end
	UIDropDownMenu_AddButton(info, UIDROPDOWN_MENU_LEVEL);


addonData["Interface"].AddDropDownItem = function(name,parent,text,isHeader,hasSubMenu,hasValue,value, tooltipTitle,tooltipText)
	local info = UIDropDownMenu_CreateInfo();
	info.text = text;

	-- Deal with Header Item
	if ( isHeader ) then
		info.isTitle = 1;
		info.notCheckable = 1;
	end
	
	-- Deal With SubMenu Items ( Not sure how to deal with this in this layout yet )
	if ( hasSubMenu ) then
		info.hasArrow = true;
	end
	
	if ( hasValue and value ) then
		info.value = value;
	end
				
	if ( tooltipTitle and tooltipText ) then
		info = addonData["Interface"].AddDropDownTooltip(info,tooltipTitle,tooltipText);
	end
	UIDropDownMenu_AddButton(info, UIDROPDOWN_MENU_LEVEL);
end

This is file 2 that define's the addon's specific menu options and their functionality on clicking them
Code:
addonData["SlashCmds"].OnMenuClick = function(self,arg1,arg2,checked)	
	if ( arg1 == 1 ) then 
		addonData["WatchFrame"].AutoHide = not addonData["WatchFrame"].AutoHide; 
	end
	if ( arg1 == 2 ) then 
		addonData["ScrollFrame"].Movable = not addonData["ScrollFrame"].Movable; 
	end
	if ( arg1 == 3 ) then 
		addonData["SlashCmds"].OnDock(); 
	end
	if ( arg1 == 4 ) then 
		addonData["SlashCmds"].OnReset();  
	end	
	if ( arg1 < 3 ) then 
		addonData["SlashCmds"].Update();
		-- If the Options frame is visible then refresh it 
		if ( addonData["Frames"].SWF_Options:IsShown() ) then addonData["SlashCmds"].OnShow(addonData["Frames"].SWF_Options); end		
	end
end

addonData["SlashCmds"].CreateMenu = function(self)
	addonData["Interface"].AddDropDownItem("OptionHeader1",self,"Scrolling Watch Frame",true);
	
	local isDisabled = false;
	local isChecked = false;

	-- Add AutoHide to the menu
	isChecked = addonData["WatchFrame"].AutoHide;
	isDisabled = false;
	if ( addonData["nUI"].InfoPanel ) then
		isDisabled = true;
		isChecked = false;
	end
	addonData["Interface"].AddDropDownClickableItem("OptionItem1",self,"Auto Hide",isDisabled,true,isChecked, addonData["SlashCmds"].OnMenuClick,1);
		
	-- Add Locked Toggle to the menu
	isChecked = not addonData["ScrollFrame"].Movable;
	isDisabled = false;
	if ( addonData["nUI"].InfoPanel ) then
		isDisabled = true;
		isChecked = false;
	end
	addonData["Interface"].AddDropDownClickableItem("OptionItem2",self,"Lock",isDisabled,true,isChecked, addonData["SlashCmds"].OnMenuClick,2);
		
	-- Add Docking Option to the menu
	local DockText = "Dock";
	if ( addonData["nUI"].InfoPanel ) then DockText = "UnDock"; end
	isChecked = addonData["nUI"].InfoPanel;
	isDisabled = false;
	if ( not addonData["nUI"].Loaded ) then
		isDisabled = true;
		isChecked = false;
	end
	addonData["Interface"].AddDropDownClickableItem("OptionItem3",self,DockText,isDisabled,true,isChecked, addonData["SlashCmds"].OnMenuClick,3);

	-- Add Reset Option to the menu
	isChecked = false;
	isDisabled = false;
	addonData["Interface"].AddDropDownClickableItem("OptionItem4",self,"Reset to Default Settings",isDisabled,false,isChecked, addonData["SlashCmds"].OnMenuClick,4);

And this is file 3 that creates the button ( inherited from OptionsButtonTemplate ) and links it to the generic click menu after assigning the menu frame to display.
Code:
	local o = addonData["Interface"].AddPushButton("WatchFrameOptionsButton","O",f)
	o:SetWidth(10);
	o:SetParent(f);
	o:RegisterForClicks("AnyDown");
	o:ClearAllPoints();
	o:SetPoint("TOPLEFT",f,"TOPLEFT",10,-10);
	o.Menu = addonData["Frames"].SWF_DropDownMenu;
	o:SetScript("OnClick",function(self,button,down)
		if ( button == "RightButton" ) then 
			addonData["Interface"].OnClick(self,button,down); 
		elseif ( button == "LeftButton" ) then
			if ( addonData["Frames"].SWF_Options:IsShown() ) then
				addonData["Frames"].SWF_Options:Hide();
			else
				addonData["Frames"].SWF_Options:Show();
			end
		end
	end);
And this code is what starts it all off in Variables_Loaded event catcher for the addon.
Code:
-- Set Up the Menu System
addonData["Frames"].SWF_DropDownMenu = 	addonData["Interface"].AddDropDownMenu("SWF_OptionsMenu",UIParent,addonData["SlashCmds"].CreateMenu,"MENU");
Here's a screenshot of what the result is. As a first attempt without using ace stuff I was surprised it worked so well so quickly rofl.
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_032810_195854.jpg
Views:	758
Size:	350.6 KB
ID:	4118  
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
03-28-10, 01:21 PM   #7
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by nightcracker View Post
Can I have some context please? Like, the code which calls the function?
Here's the dropdown code from CFM containing the lines referenced in the stack.

lua Code:
  1. function CFM_CreateProps()
  2.     --[[ STRATA DATA ]]
  3.     fs = f:CreateFontString("CFM_StrataText")
  4.         fs:SetFontObject("GameFontGreenSmall")
  5.         fs:SetJustifyH("RIGHT")
  6.         fs:SetText("Strata:")
  7.         fs:SetPoint("BOTTOMLEFT", CFM_ChangeParentText, "TOPLEFT", 5,12)   
  8.        
  9.     dm = CreateFrame("Frame", "CFM_StrataBox", f, "UIDropDownMenuTemplate")
  10.         dm:SetPoint("LEFT", CFM_StrataText, "RIGHT", -10, -2)
  11.         dm:SetScale(.75)
  12.         UIDropDownMenu_SetWidth(dm,105)
  13.         UIDropDownMenu_Initialize(dm, CFM_StrataDropInit) -- LINE 811
  14. end
  15.  
  16. function CFM_StrataDropInit()
  17.     level = level or 1
  18.     local info = UIDropDownMenu_CreateInfo()
  19.     info.text = "BACKGROUND"
  20.     info.value = 0
  21.     info.func = function() CFM_StrataBoxClick() end
  22.     info.owner = this:GetParent()
  23.     info.checked = nil
  24.     info.icon = nil
  25.     UIDropDownMenu_AddButton(info, level) -- LINE 1049
  26.    
  27.     info.text = "LOW"
  28.     info.value = 1
  29.     info.func = function() CFM_StrataBoxClick() end
  30.     info.owner = this:GetParent()
  31.     info.checked = nil
  32.     info.icon = nil
  33.     UIDropDownMenu_AddButton(info, level)
  34.    
  35.     info.text = "MEDIUM"
  36.     info.value = 2
  37.     info.func = function() CFM_StrataBoxClick() end
  38.     info.owner = this:GetParent()
  39.     info.checked = nil
  40.     info.icon = nil
  41.     UIDropDownMenu_AddButton(info, level)
  42.    
  43.     info.text = "HIGH"
  44.     info.value = 3
  45.     info.func = function() CFM_StrataBoxClick() end
  46.     info.owner = this:GetParent()
  47.     info.checked = nil
  48.     info.icon = nil
  49.     UIDropDownMenu_AddButton(info, level)
  50.    
  51.     info.text = "DIALOG"
  52.     info.value = 4
  53.     info.func = function() CFM_StrataBoxClick() end
  54.     info.owner = this:GetParent()
  55.     info.checked = nil
  56.     info.icon = nil
  57.     UIDropDownMenu_AddButton(info, level)
  58.                
  59.     info.text = "TOOLTIP"
  60.     info.value = 5
  61.     info.func = function() CFM_StrataBoxClick() end
  62.     info.owner = this:GetParent()
  63.     info.checked = nil
  64.     info.icon = nil
  65.     UIDropDownMenu_AddButton(info, level)
  66. end

In all honesty, I have not idea what I'm doing with drop frames. I'm just copying from what I've gathered from wowwiki.

Last edited by Sythalin : 03-28-10 at 01:45 PM.
  Reply With Quote
03-28-10, 01:50 PM   #8
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
What value do you want info.owner to be ?
"this" is a global set by wow to the frame which got the event.
"self" is a local and it's your job that is has the right value.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
03-28-10, 02:28 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
"this" is also deprecated
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-28-10, 02:43 PM   #10
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Rilgamon View Post
What value do you want info.owner to be ?
"this" is a global set by wow to the frame which got the event.
"self" is a local and it's your job that is has the right value.
Here's the gist of things. A user clicks a frame in a scroll list and it's supposed to fill the saved values in the fields/boxes. In this case, the user would use the dropdown to change the value for anchor points and strata.

In attempts to revert the change that started this, I placed the GUI code back into the main file and still getting the same errors. Kinda irked now since I never had this issue until recently.

It's a constant "listFrame is nil", which makes no sense since a) I declare "level" myself and b) Blizz already sets a default in the event that "level" isn't declared at all. Yet there it is.

EDIT: Ok, I just loaded it on my test toon (no other addons) and now it's working flawlessly. Time to go track my tainter.....

Last edited by Sythalin : 03-28-10 at 02:46 PM.
  Reply With Quote
03-28-10, 02:51 PM   #11
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Originally Posted by ChaosInc View Post
a) I declare "level" myself and
After you changed level to a local thats true. When it was a global
you had no code that made sure that level was set correctly.

Your code was

Code:
 level = level or 1
When another addon or blizz has a global level with the value "good".
You will pass this to the function and not 1.

Originally Posted by ChaosInc View Post
b) Blizz already sets a default in the event that "level" isn't declared at all. Yet there it is.
Yes. And since you dont change your level you dont need to declare it at all.

Edit:

Code:
local listFrame = _G["DropDownList"..level]
This is the line that generates listFrame ... so when it is nil this can be
because level is set wrong or the global _G["DropDownList"..level] is nil.
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 03-28-10 at 02:57 PM.
  Reply With Quote
03-28-10, 02:59 PM   #12
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
...
.....
.....

ARGGGG!

Well, it's another "addon" tainting stuff up: guildlaunch's profiler.

And like a moron, I didn't take the "standard" debug test of trying mine solo to verify functionality. *slaps own hand*

Sorry to get everyone up for this. I'll be contacting guildlaunch about their profiler causing taint in other addons.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Confusing error, need some help


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off