WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Hooking function when other addons are using local copies of it (https://www.wowinterface.com/forums/showthread.php?t=57360)

vaindil 08-16-19 10:58 AM

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?

Kanegasi 08-16-19 03:29 PM

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.

vaindil 08-16-19 05:41 PM

Quote:

Originally Posted by Kanegasi (Post 333237)
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?

Kanegasi 08-16-19 05:56 PM

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.

vaindil 08-17-19 09:48 AM

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!


All times are GMT -6. The time now is 02:21 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI