Thread Tools Display Modes
08-16-19, 10:58 AM   #1
vaindil
A Murloc Raider
 
vaindil's Avatar
Join Date: Jan 2015
Posts: 6
Hooking function when other addons are using local copies of it

I use an addon that calls hooksecurefunc on TaxiRequestEarlyLanding. I also use a UI addon that replaces the Blizzard button that actually calls that function. The UI is using a local copy of the function, so the hook is never called.

What's the correct way for this situation to be handled? ElvUI does the same thing as the UI that I use, so I assume using a local copy of the function is fine. How is an addon supposed to hook a function when other addons may not trigger the hook?
  Reply With Quote
08-16-19, 03:29 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Don't use a local copy.

Localizing a function provides a minor performance increase for functions called often, especially each frame. This function is single use when the user requests it during a flight, it's silly to localize it.
  Reply With Quote
08-16-19, 05:41 PM   #3
vaindil
A Murloc Raider
 
vaindil's Avatar
Join Date: Jan 2015
Posts: 6
Originally Posted by Kanegasi View Post
Don't use a local copy.

Localizing a function provides a minor performance increase for functions called often, especially each frame. This function is single use when the user requests it during a flight, it's silly to localize it.
This makes sense to me, but I can't control what other addons are doing, unfortunately. Maybe this hypothetical doesn't make sense, but what if an addon needed to hook one of those functions that it DOES make sense to localize? Are you just SOL?
  Reply With Quote
08-16-19, 05:56 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Oh, oops, I misread. I thought you were the one using a local copy. hooksecurefunc propagates local pointers as long as you hook before any localizations happen.

If you are in control of the addon that hooks, look into the UI addon and see where it localizes. It most likely localizes at file load, so you'll have to put a ! in front of your addon's folder name and toc file to make sure you load before the UI addon. If it localizes at PLAYER_LOGIN, you can hook anytime before that, such as file load or ADDON_LOADED.

If it's not your add-on, suggest what I suggested to the authors, preferably getting the UI addon author to not localize.

Last edited by Kanegasi : 08-16-19 at 06:00 PM.
  Reply With Quote
08-17-19, 09:48 AM   #5
vaindil
A Murloc Raider
 
vaindil's Avatar
Join Date: Jan 2015
Posts: 6
I asked the UI author and was told that hooking Blizzard's TaxiRequestEarlyLanding functionality explicitly should not carry over to the UI's button (which does the exact same thing and nothing else). Can't do much about that, unfortunately. Thanks for your time, I really appreciate it!

Last edited by vaindil : 08-17-19 at 09:58 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hooking function when other addons are using local copies of it

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