Thread Tools Display Modes
04/20/15, 12:59 PM   #1
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Access a private function ShowMenu Bug

Code:
EsoUI/Ingame/Inventory/InventorySlot.lua:903: attempt to access a private function 'PickupInventoryItem' from insecure code
stack traceback:
EsoUI/Ingame/Inventory/InventorySlot.lua:903: in function 'InitiateDestroyItem'
EsoUI/Ingame/Inventory/InventorySlot.lua:1453: in function 'OnSelect'
EsoUI/Libraries/ZO_ContextMenus/ZO_ContextMenus.lua:412: in function 'ZO_Menu_ClickItem'
8371350907706105899:4: in function '(main chunk)'
Report here:
Error deleting items every few hours.
=(
Looking for addon causing a bug

Any addon showing a context-menu can causes it. But there is nothing wrong with the calling:
ClearMenu() AddMenuItem ... ShowMenu(), right?

How to reproduce:
Do in chat window:
1. /reloadui
2. /script ClearMenu() AddMenuItem("") ShowMenu() ClearMenu()
3. Go and use an item of your inventory using context-menu

unsecure code?!?

Try this:
1. /reloadui
2. go and open journal and right-click a quest to open a context-menu. In fact any build-in context-menu would be ok. You could also open the context-menu of the inventory.
3. /script ClearMenu() AddMenuItem("") ShowMenu() ClearMenu()
4. Go and use an item of your inventory using context-menu

now the same code is secure.

The critical call is AddMenuItem("")
Here is another example:
"secure" code adding a normal button below the context-menu
Lua Code:
  1. local good = WINDOW_MANAGER:CreateControlFromVirtual("GoodBoy", ZO_Menu, "ZO_DefaultButton")
  2. good:SetDimensions(320, 32)
  3. good:SetAnchor(TOPLEFT, nil, BOTTOMLEFT)
  4. good:SetText("Click me")

"unsecure" code adding a ZO_MenuItem control.
Lua Code:
  1. local bad = WINDOW_MANAGER:CreateControlFromVirtual("BadBoy", ZO_Menu, "ZO_MenuItem")
  2. bad:GetNamedChild("Name"):SetText("Click me")
  3. bad:SetAnchor(TOPLEFT, nil, BOTTOMLEFT)
  4. bad:SetHidden(false)
It depends on who uses the template ZO_MenuItem first?!?

Seems to be a game-in bug. Or AddMenuItem should not be public. What else should be used?
  Reply With Quote
04/20/15, 04:28 PM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
We could create a library that does exactly the same thing as the ingame menu and use that instead
  Reply With Quote
04/21/15, 01:47 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by sirinsidiator View Post
We could create a library that does exactly the same thing as the ingame menu and use that instead
That is "Plan B". Because we need to use templates. And templates require XML. And XML can not be used from embedded libs.
Therefore I hoped ZOS would respond to this post.

A library needs cooperation from addon developers. It's worthless to write a lib, if everybody says "My code is working without". And basically that is true, because it's just the build-in code that does not work anymore

The main key to avoid this error is:
Never create an instance of ZO_MenuItem from addon code
=> Never use ZO_Menu.itemPool, so that build-in code does not re-use pooled controls created by addon code
=> Never use AddMenuItem

A library could introduce "AddCustomMenuItem", which uses its own pool using a template that mimics ZO_MenuItem.
(The ZO_Menu.checkBoxPool respectively)

But as far as I know, this must be a shared addon. Maybe a more experienced author finds a better solution?

Last edited by votan : 04/21/15 at 03:17 AM.
  Reply With Quote
04/21/15, 04:07 AM   #4
QuadroTony
Banned
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 828
How to reproduce:
Do in chat window:
1. /reloadui
2. /script ClearMenu() AddMenuItem("") ShowMenu() ClearMenu()
3. Go and use an item of your inventory using context-menu
cant reproduce
  Reply With Quote
04/21/15, 04:13 AM   #5
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by QuadroTony View Post
cant reproduce
Really?!? Wow. Am I the only one!?!
  Reply With Quote
04/21/15, 04:17 AM   #6
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
You just misswritten it.

it's :

/reloadui
/script ClearMenu()
/script AddMenuItem("")
/script ShowMenu()
/script ClearMenu()

Right click on an item > Delete : bug



I can reproduce the problem too.
  Reply With Quote
04/21/15, 04:25 AM   #7
QuadroTony
Banned
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 828
Originally Posted by Ayantir View Post
You just misswritten it.

it's :

/reloadui
/script ClearMenu()
/script AddMenuItem("")
/script ShowMenu()
/script ClearMenu()

Right click on an item > Delete : bug



I can reproduce the problem too.
yes!! i can reproduce it now

btw after this
/script ShowMenu()

i got a visual glitch
  Reply With Quote
04/21/15, 04:30 AM   #8
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by Ayantir View Post
You just misswritten it.

it's :

/reloadui
/script ClearMenu()
/script AddMenuItem("")
/script ShowMenu()
/script ClearMenu()

Right click on an item > Delete : bug



I can reproduce the problem too.
Thanks Ayantir! I'm not nuts. (not fully )
Separating commands by space in one line works for me. But ok.... that's better. Thanks again.

And thanks QuadroTony.
The glitch is nearly as expected. The context-menu should be empty. That's what ShowMenu does. But what is this blue thing?

Last edited by votan : 04/21/15 at 04:33 AM.
  Reply With Quote
04/21/15, 04:40 AM   #9
QuadroTony
Banned
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 828
when i mouseover this thing it become blue
like any context menu string when you mouseover it
  Reply With Quote
04/21/15, 04:46 AM   #10
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by QuadroTony View Post
when i mouseover this thing it become blue
like any context menu string when you mouseover it
It's not visual glitch, it works correctly. Script shows context menu with one item (one row), with no name ("", no text on the line) and when you point mouse over this item, it is highlighted.
  Reply With Quote
04/21/15, 04:47 AM   #11
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by QuadroTony View Post
when i mouseover this thing it become blue
like any context menu string when you mouseover it
of course..... it's time for lunch
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Access a private function ShowMenu Bug


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