Quantcast ESOUI - View Single Post - Update 5.2
Thread: Update 5.2
View Single Post
10/03/19, 09:19 AM   #5
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,621
The following kind of "Post HooK" code, which is used in some addons which got to do with crafting...
currently makes the PickupInventoryItem code insecure...
Code:
EsoUI/Ingame/Inventory/InventorySlot.lua:2630: Attempt to access a private function 'PickupInventoryItem' from insecure code. The callstack became untrusted 3 stack frame(s) from the top.
stack traceback:
EsoUI/Ingame/Inventory/InventorySlot.lua:2630: in function '(anonymous)'
|caaaaaa<Locals> inventorySlot = ud, bag = 6, index = 39 </Locals>|r
EsoUI/Ingame/Utility/ZO_SlotUtil.lua:14: in function 'RunHandlers'
|caaaaaa<Locals> handlerTable = [table:1]{}, slot = ud, handlers = [table:2]{}, i = 1 </Locals>|r
(tail call): ?
ZO_StackSplitSource_DragStart:4: in function '(main chunk)'
|caaaaaa<Locals> self = ud, button = 1 </Locals>|r

if you try to drag any item from the crafting table inventory row:

Lua Code:
  1. local origSmithingSetMode = ZO_Smithing.SetMode
  2.     ZO_Smithing.SetMode = function(smithingCtrl, mode, ...)
  3.         local retVar = origSmithingSetMode(smithingCtrl, mode, ...)
  4.         ---Your addon post hook code here
  5.         return retVar

Same for ZO_Enchanting.OnModeUpdated!

Error happens at the craftbag as well then as it seems.

Hope we can get another working PostHook so addons lik AdvancedFilters and others can work together without problems. In the past it had to be the posthook and to ZO_Smithing and ZO_Enchanting to make them all work together.

Edit
Info from sirinsidiator for SMITHING
That's because SetMode calls the SetHidden method for each panel, which in turn calls PerformFullRefresh on the crafting intenvories down the line, which is what creates the inventory slots.

You could try to hook into e.g. SMITHING.researchPanel.SetHidden instead.
It is the last function call in SetMode and it doesn't use a craftinginventory so cannot taint any code.
If you PreHook it and use something like
Lua Code:
  1. local smithingMode = SMITHING.mode
you can run your code with the smithingMode variable again.
Smithing - Alternative
You can also PreHook EACH panel's SetHidden function of the SMITHING variable (like SMITHING.refinePanel or SMITHING.deconstructionPanel) and execute your code there.

Attention:
But the SetHidden function is called for EACH panel of the crafting table (e.g. refine, create, deconstruction, improve, research, furniture recipes) EACH time you change ANY of them.
So if you change from deconstruction to refine, deconstruction will be SetHidden(true), refine will be SetHidden(false) and ALL others will be SetHidden(true) as well! So be sure to check if the isHidden parameter is false to "apply your code at this panel properly", and check which panel you currently are inside your function code.

Enchanting
Both way unfortunately do not work for ENCHANTING as it does not own any "panels", just ENCHANTING.
If your ENCHANTING PostHook of OnModeUpdateddoes not work anymore you can try this tricky solution provided by Shinni e.g. (untested!)
Lua Code:
  1. local secondCall = false
  2. local isPreHook = false
  3.  
  4. ZO_PreHook(ZO_Smithing, "SetMode", function(self, mode)
  5.     if not isPreHook then
  6.         -- this is actually a post hook
  7.         -- do stuff here
  8.         return true -- prevent 2nd execution of SetMode
  9.     end
  10. end)
  11.  
  12. ZO_PreHook(ZO_Smithing, "SetMode", function(self, mode)
  13.     if not secondCall then
  14.         secondCall = true
  15.         return self.SetMode(self, mode)
  16.     end
  17.     isPreHook = true
  18. end)
Should work for ZO_Enchanting, "OnModeUpdated" as well.

Or use a Zo_PreHook to ENCHANTING.OnModeUpdated with zo_callLater (about 25ms should be enough) to get the correct enchantingMode again.

Last edited by Baertram : 10/03/19 at 11:32 AM.
  Reply With Quote