Thread Tools Display Modes
09-01-10, 11:24 PM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Need help with debugging Cata changes...

Seems Blizz finally got around to nixing "this" from their old libraries, which is screwing up my dropdown menus now (they were built off the old templates). So I've been spending the last hour or so trying to figure out how to fix them for "self". I've almost got it, until an option in a dropdown is clicked:

Error:
Code:
Message: Interface\FrameXML\UIDropDownMenu.lua:915: attempt to index local 'filterText' (a nil value)
Time: 09/02/10 00:15:31
Count: 2
Stack: Interface\FrameXML\UIDropDownMenu.lua:915: in function `UIDropDownMenu_SetText'
Interface\FrameXML\UIDropDownMenu.lua:506: in function `UIDropDownMenu_Refresh'
Interface\FrameXML\UIDropDownMenu.lua:561: in function `UIDropDownMenu_SetSelectedValue'
Interface\AddOns\CFM\CFM_GUI.lua:1167: in function `CFM_ToBoxClick'
Interface\AddOns\CFM\CFM_GUI.lua:1019: in function `func'
Interface\FrameXML\UIDropDownMenu.lua:636: in function `UIDropDownMenuButton_OnClick'
[string "*:OnClick"]:1: in function <[string "*:OnClick"]:1>

Locals: frame = CFM_PropFrame {
 selectedValue = 0
 0 = <userdata>
}
text = "CENTER"
filterText = nil
(*temporary) = "CFM_PropFrameText"
(*temporary) = nil
(*temporary) = "CFM_PropFrame"
(*temporary) = "attempt to index local 'filterText' (a nil value)"
Code:
lua Code:
  1. --[[ RELATIVEPOINT DATA ]]         
  2.     dm = CreateFrame("Frame", "CFM_ToBox", f, "UIDropDownMenuTemplate")
  3.         dm:SetPoint("LEFT", CFM_ToText, "RIGHT", -10, -2)
  4.         dm:SetScale(.75)
  5.         UIDropDownMenu_SetWidth(dm,105)
  6.         UIDropDownMenu_Initialize(dm, CFM_ToDropInit)
  7.  
  8. function CFM_ToDropInit(self)
  9.     local level = level or 1
  10.     local info = UIDropDownMenu_CreateInfo()
  11.     info.text = "CENTER"
  12.     info.value = 0
  13.     info.func = function(self) CFM_ToBoxClick(self) end    -- LINE 1019
  14.     info.owner = self:GetParent()
  15.     info.checked = nil
  16.     info.icon = nil
  17.     UIDropDownMenu_AddButton(info, level)
  18. end
  19.  
  20. function CFM_ToBoxClick(self)
  21.     UIDropDownMenu_SetSelectedValue(self.owner, self.value)  -- LINE 1167
  22.     if (self.value == 0) then
  23.         activeProfile[selFrame].relativePoint = "CENTER"
  24.     end
  25.     CFM_ApplySettings(selFrame)
  26. end

I've looked for API changes for the drop menus, but haven't seem to find them. The old version still works in live.
  Reply With Quote
09-02-10, 12:36 AM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Methinks you need to be more descriptive with your function parameters.

Inside of

Code:
function CFM_ToDropInit(self)
...you then define this:

Code:
info.func = function(self) CFM_ToBoxClick(self) end
Which "self" is being referenced there? The parameter for CFM_ToDropInit(), or the new one declared for info.func?

You could also forego what you have now with this:

Code:
info.func = CFM_ToBoxClick
...which would probably work exactly as you intended with the added benefit of not generating an anonymous function every time CFM_ToDropInit() is called.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-02-10, 12:38 AM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Torhal View Post
Methinks you need to be more descriptive with your function parameters.

Inside of

Code:
function CFM_ToDropInit(self)
...you then define this:

Code:
info.func = function(self) CFM_ToBoxClick(self) end
Which "self" is being referenced there? The parameter for CFM_ToDropInit(), or the new one declared for info.func?
Hrm, point taken. I'll toy with that tomorrow. Too late and too tired to think clearly at this point. I was just following what I could find on dropdowns at the time.
  Reply With Quote
09-02-10, 12:40 AM   #4
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Meh. Seems you read my post before I edited it - please re-read
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-02-10, 12:44 AM   #5
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Torhal View Post
Meh. Seems you read my post before I edited it - please re-read
I saw it. No worries. Like I said, I'll play with it tomorrow.
  Reply With Quote
09-02-10, 11:05 AM   #6
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Still ends in the "filterText = nil" error after trying the suggested and several other changes. Grrr....

Here's the dropdown from the original that needs to be converted from this.

lua Code:
  1. dm = CreateFrame("Frame", "CFM_ToBox", f, "UIDropDownMenuTemplate")
  2.         dm:SetPoint("LEFT", CFM_ToText, "RIGHT", -10, -2)
  3.         dm:SetScale(.75)
  4.         UIDropDownMenu_SetWidth(dm,105)
  5.         UIDropDownMenu_Initialize(dm, CFM_ToDropInit)
  6.  
  7. function CFM_ToDropInit()
  8.     local level = level or 1
  9.     local info = UIDropDownMenu_CreateInfo()
  10.    
  11.     info.text = "CENTER"
  12.     info.value = 0
  13.     info.func = function() CFM_ToBoxClick() end
  14.     info.owner = this:GetParent()
  15.     info.checked = nil
  16.     info.icon = nil
  17.     UIDropDownMenu_AddButton(info, level)
  18.  
  19.     info.text = "TOP"
  20.     info.value = 1 -- and so on....
  21. end
  22.  
  23. function CFM_ToBoxClick()
  24.     UIDropDownMenu_SetSelectedValue(this.owner, this.value)
  25.     if (this.value == 0) then
  26.         activeProfile[selFrame].relativePoint = "CENTER"
  27.     elseif (this.value == 1) then -- and so on....
  28.     end
  29.     CFM_ApplySettings(selFrame)
  30. end

I haven't had issues getting it converted up until the CFM_ToBoxClick call when someone chooses an option. Always ends in the filterText = nil error; I'm guessing something has been added that I can't seem to find.
  Reply With Quote
09-02-10, 11:21 AM   #7
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
It may be something to do with the UIDropDownTemplate, which you honestly don't need to use. For a rather comprehensive tutorial on DropDownMenus, see this thread.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-02-10, 11:37 AM   #8
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Torhal View Post
It may be something to do with the UIDropDownTemplate, which you honestly don't need to use. For a rather comprehensive tutorial on DropDownMenus, see this thread.
Thanks for the link. I was looking for an explanation like this since I started working with dropboxes, finding the "official" guides confusing and bloated. I'll skim it over and post back on it.
  Reply With Quote
09-02-10, 12:26 PM   #9
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Code:
info.owner = this:GetParent()
Your issue is that the this in that code is not the self passed to the initialization function. Use:

Code:
info.owner = self
  Reply With Quote
09-02-10, 12:37 PM   #10
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by ChaosInc View Post
Thanks for the link. I was looking for an explanation like this since I started working with dropboxes, finding the "official" guides confusing and bloated. I'll skim it over and post back on it.
Awesome info. However, it just covers the popup menu and not the original option/button frame (if that makes sense), which I have to go look up in the XML files. It's easier to just use the template to start with for what I want to do. I'll keep the info in mind for later reference (such as LDB mods).

However:
Code:
info.func = CFM_ToBoxClick
Code:
info.owner = self
The combination of both of these have solved the problem. Thanks guys.
  Reply With Quote
09-07-10, 12:10 PM   #11
Tomate
A Murloc Raider
 
Tomate's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 5
Thanks for the help in this topic.
It helps me a lot.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with debugging Cata changes...

Thread Tools
Display Modes

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