WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   UIDropDownMenu Assumed Taint (https://www.wowinterface.com/forums/showthread.php?t=58019)

kaytotes 05-23-20 10:02 AM

UIDropDownMenu Assumed Taint
 
I try to avoid posting bothering people on here with something that is probably trivial but I'm stumped and at my whits end. As far as I know this was working fine with 8.1 and 8.2 so maybe I missed something about API changes with 8.3.

Basically I'm getting the following in at least 2 places that have been found so far.

https://github.com/kaytotes/Improved...dUI/issues/139
https://github.com/kaytotes/Improved...dUI/issues/140

Clicking "Guild" on my micro menu.

The specific line in question being: https://github.com/kaytotes/Improved....lua#L108-L112

Code:

29x FrameXML\UIDropDownMenu.lua:340: attempt to index local 'listFrame' (a nil value)
[string "@FrameXML\UIDropDownMenu.lua"]:340: in function `UIDropDownMenu_AddButton'
[string "@Blizzard_Communities\ClubFinder.lua"]:559: in function `initFunction'
[string "@FrameXML\UIDropDownMenu.lua"]:76: in function `UIDropDownMenu_Initialize'
[string "@Blizzard_Communities\CommunitiesSettings.lua"]:43: in function <Blizzard_Communities\CommunitiesSettings.lua:34>
[string "=[C]"]: in function `LoadAddOn'
[string "@FrameXML\UIParent.lua"]:457: in function `UIParentLoadAddOn'
[string "@FrameXML\UIParent.lua"]:707: in function `Communities_LoadUI'
[string "@FrameXML\UIParent.lua"]:973: in function `ToggleCommunitiesFrame'
[string "@FrameXML\UIParent.lua"]:828: in function <FrameXML\UIParent.lua:807>
[string "=[C]"]: in function `securecall'

Attempting to favourite a set in collections.

Code:

31x FrameXML\UIDropDownMenu.lua:340: attempt to index local 'listFrame' (a nil value)
[string "@FrameXML\UIDropDownMenu.lua"]:340: in function `UIDropDownMenu_AddButton'
[string "@Blizzard_Communities\ClubFinder.lua"]:559: in function `initFunction'
[string "@FrameXML\UIDropDownMenu.lua"]:76: in function `UIDropDownMenu_Initialize'
[string "@Blizzard_Communities\CommunitiesSettings.lua"]:43: in function <Blizzard_Communities\CommunitiesSettings.lua:34>
[string "=[C]"]: in function `LoadAddOn'
[string "@FrameXML\UIParent.lua"]:457: in function `UIParentLoadAddOn'
[string "@FrameXML\UIParent.lua"]:707: in function `Communities_LoadUI'
[string "@FrameXML\UIParent.lua"]:973: in function `ToggleCommunitiesFrame'
[string "@FrameXML\UIParent.lua"]:828: in function <FrameXML\UIParent.lua:807>
[string "=[C]"]: in function `securecall'
[string "@ImprovedBlizzardUI\modules/bars/micromenu.lua"]:111: in function `func'

I've bounced around over the years so have seen the various issues with dropdown taint and have tried to pull in these two libs on seperate occasions to try solve the problem. Thinking this was the right course of action.

https://www.wowace.com/projects/libuidropdownmenu
https://www.wowinterface.com/downloa...pDownMenu.html

I build the micro menu here: https://github.com/kaytotes/Improved...romenu.lua#L39
Use it here: https://github.com/kaytotes/Improved...romenu.lua#L69

Swapping those out for the above replacements however hasn't solved the problem that I expected.

I am using the following 3rd party libs and wondered if maybe they could somehow be a cause but doubt it: LibStub, Ace3, CallbackHandler-1.0, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets.

Basically. What am I doing wrong?

kurapica.igas 05-23-20 07:23 PM

This is not a taint, since the error message say the "listFrame" doesn't existed, so according to the code line

Lua Code:
  1. local listFrame = _G["DropDownList"..level];

The ui drop down menu provided by the blz has only two levels, limited by "UIDROPDOWNMENU_MAXLEVELS". So if you want use more levels, the error will be raised. I don't check the 3rd libs, according to the page, if you use NoTaint UIDropDownMenu, you may change the LIB_UIDROPDOWNMENU_MAXLEVELS to a more big value.

If you still have problem, I also have a lib for drop down menu, you can search ShowDropDownMenu in https://github.com/kurapica/Scorpio/.../004.widget.md

kaytotes 05-24-20 04:02 PM

I'm sorry but I do not understand your solution. Changing that constant doesn't solve the problem either and I still get the listFrame error.

My question is why am I getting this error? I don't even know what a listframe is.

sylvanaar 05-24-20 04:42 PM

There is a huge bug IMO in the blizzard code.


ClubFinder.lua:559

Lua Code:
  1. UIDropDownMenu_AddButton(info, level);

In this code "level" is a GLOBAL!

This means that it could be interacting with other code that sets the global "level" variable!

So if you are lucky that level variable will be nil, and when you call into AddButton, it will get set to 1 by this code

Lua Code:
  1. if ( not level ) then
  2.         level = 1;
  3.     end


So, that is all well and good - but it is breaking for you. So let check out your code to see if you might be using the same variable.

https://sourcegraph.com/github.com/k...yer.lua#L121:5

You also appear to be writing to the global "level" variable

Lua Code:
  1. level = UnitLevel('player');

You should try to avoid writing to global variables if at all possible. Cheers!

kaytotes 05-24-20 05:00 PM

Oh my god that's it as soon as I saw it clicked.

I'd just been going through my .TOC file and removing modules line by line to find a culprit for the error and narrowed it down to my player.lua and target.lua

I'll make a far more concerted effort to use local wherever appropriate! Thank you so much i've been tearing my hair out for a couple weeks.

Xrystal 05-24-20 05:35 PM

Quote:

Originally Posted by kaytotes (Post 336029)
Oh my god that's it as soon as I saw it clicked.

I'd just been going through my .TOC file and removing modules line by line to find a culprit for the error and narrowed it down to my player.lua and target.lua

I'll make a far more concerted effort to use local wherever appropriate! Thank you so much i've been tearing my hair out for a couple weeks.


don't forget you can also use addon wide variables via the shared table you can access at the top of each lua file.

If you have never used it, do something similar to the following at the top of any file you want to access the addon wide table. The second line is just something I add in case it is initially nil rather than an empty table.
local addonName, addonData = ...
addonData = addonData or {}

I use local for variables that are only needed for that file, or within code blocks and anything that I need access to across the whole addon I used the addonData table. This enables me to separate functionality across multiple files, which enables me to better share individual files with other addons that need the same functionality. Such as Translation tools.

Rilgamon 05-25-20 08:49 AM

Dont feel bad ;) it seems there are quite some addons using level as a global ...

https://www.townlong-yak.com/globe/wut/#q:level


All times are GMT -6. The time now is 05:00 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI