Thread Tools Display Modes
08-29-12, 02:50 PM   #1
LanceDH
A Cyclonian
 
LanceDH's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 41
Addon calling protected function while it shouldn't

Greetings,

I have an addon that I updated for 5.0.4 just now and since that it ended up causing problems.
Whenever I try to click a glyph to acivate, I get this:
'BGStats has been blocked from an action only available to the Blizzard UI'
And my bugsack end up with:
6x [ADDON_ACTION_FORBIDDEN] AddOn "BGStats" tried to call the protected function "CastGlyph()".
!BugGrabber-r188\BugGrabber.lua:587: in function <!BugGrabber\BugGrabber.lua:587>
<in C code>
Blizzard_GlyphUI\Blizzard_GlyphUI-1.0.lua:527: in function "GlyphFrameSpell_OnClick"
<string>:"*:OnClick":1: in function <string>:"*:OnClick":1

Locals:
nil
Now the problem is, nowhere in my addon did I use CastGlyph() and the addon as a whole has nothing to do with it.
I'm hoping someone has the time to read through the addon and can help figure out the problem.
I also hope the addon isn't too hard to read.

LanceDH
Attached Files
File Type: lua BGStats.lua (40.6 KB, 508 views)
  Reply With Quote
08-29-12, 02:59 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Its a blizzard problem I think. Similar to the focus problem I suspect that addons have.

I found that left clicking on the glyph it doesn't like but right clicking doesn't kick up an error and I don't have the addon you're talking about but any addon seems to kick up a fuss the moment you touch it.
__________________


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
08-29-12, 03:09 PM   #3
LanceDH
A Cyclonian
 
LanceDH's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 41
Both left and right clicking does it for me.
I can just ignore the error and click again, but it would be fairly annoying.
If I disable the addon it doesn't happen at all.
  Reply With Quote
08-29-12, 03:33 PM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by LanceDH View Post
Both left and right clicking does it for me.
I can just ignore the error and click again, but it would be fairly annoying.
If I disable the addon it doesn't happen at all.
You're leaking globals.

Try putting
Code:
local _
at the top of your file, just under the
----------------------------------------
-- Variables
----------------------------------------
  Reply With Quote
08-29-12, 03:36 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
thanks tukz.

Thought Id resolved it with the removal of the _ variables in nUI but it seems it resurfaced a few patches later but I didn't notice.
__________________


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
08-29-12, 03:50 PM   #6
LanceDH
A Cyclonian
 
LanceDH's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 41
Originally Posted by Dridzt View Post
You're leaking globals.

Try putting
Code:
local _
at the top of your file, just under the
----------------------------------------
-- Variables
----------------------------------------
Totally forgot about that.
That seems to have fixed it.
I'll have to switch around characters and such to see if it stays fixed.
Wonder why that only ended up being a problem now.
  Reply With Quote
08-29-12, 06:18 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Because Blizzard is also leaking a global _ variable.
__________________
"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
08-31-12, 05:13 PM   #8
Atherinas
A Defias Bandit
Join Date: Feb 2009
Posts: 3
I've been having the same problem with a bunch of non glyph related addons since 5.0.4 ,but i didn't understand a THING () about all those leaking stuffs :P
Any chance I could get dumb-as-brick solution ?

Ok,on a more serious note, I know this is labeled "Lua/Xml Help" and i got no clue about any of those,thing is that i do have that problem though, and googling for 2 hours now has come up with ZIP!

So any help for the non-programming ones would be much appreciated

Last edited by Atherinas : 08-31-12 at 05:16 PM.
  Reply With Quote
08-31-12, 06:18 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you're not willing to edit the Lua code of the addons causing the problems, then you will need to wait for their authors to update, or find other addons that are already up to date.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-31-12, 06:41 PM   #10
Atherinas
A Defias Bandit
Join Date: Feb 2009
Posts: 3
I am, i was just asking if its something simple as adding a line somewhere, or something like that.
I just asked if a little more "in depth" info was possible.In depth for my level of lua knowledge :P

What i got from Dridzt's post was to place " local _ " under the Variables line in the start of the Lua :P
  Reply With Quote
08-31-12, 07:42 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can do that, and it will work, though it's not the optimal solution, and if the addon hasn't been updated since the patch it may need other changes too. If you still get errors afterward, you'll have to post the errors; make sure Lua errors are enabled under Interface Options > Help.

Basically what's happening is that "_" is the name of a variable -- a "bucket" addons can put information into. Each bucket can only hold one piece of information at a time (one number, one text string, one table of values, etc.), and there are two types of buckets.

A "global" bucket is one that all addons (and the default UI code) can see, put information into, or take information out of.

A "local" bucket is one that is visible only inside the "scope" where it was created. If the bucket is created at the top of the file, then all of the code inside that file can see and access the bucket, but the bucket is invisible and inaccessible to all code in all other files. If the bucket is created inside a function or loop or do/end block, then only the code inside that function or loop or do/end block can see and use it.

Now the problem in this case is that Blizzard creates a global bucket named _, and puts some information into it. They didn't mean to make it a global bucket, but whoever wrote that code forgot to make it local, so it's global.

Now your addon comes along and looks for a global bucket named _. If Blizzard hadn't already made it, your addon would make a new bucket and put something in it. But, since the bucket already exists, your addon dumps out whatever is already in the bucket, and puts its own information in.

Now even though Blizzard wasn't using that bucket anymore, their code goes "hey, that addon's messing with my bucket! help! taint!" and the taint police come running, and put up crime scene tape around the bucket, causing problems for anyone who wanted to use it.

In this case, it's relatively straightforward. In other cases, however, the taint police are not very good at their job, and will do something like "hey, that addon had a drink in the same bar as this other addon that once went to grade school with this third addon that once bumped into this fourth addon on the street, and that fourth addon's second cousin's son in law knocked over my bucket... it must be the first addon's fault!" and report something completely useless.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-31-12, 07:49 PM   #12
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Phanx View Post
Now even though Blizzard wasn't using that bucket anymore, their code goes "hey, that addon's messing with my bucket! help! taint!" and the taint police come running, and put up crime scene tape around the bucket, causing problems for anyone who wanted to use it.
ROFL!! This is the best description of taint

Question - If you have only one addon running are the taint police accurate then? Or can they still report irrelevant lines of code?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Addon calling protected function while it shouldn't


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