View Single Post
04/25/15, 08:47 PM   #10
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Baertram View Post
So how do we prevent this to happen? I've added a check into event single inventory slot update to ask if the item is new and if the item type is not the one for item got deleted. Any other checks to do here to avoid the problem?
I would say it depends on when you really need to run code. By that I mean why are you watching for the slot updates? If you don't need to process old items then checking if its new should prevent most of the problems.
Does the addon really need to update data on slot update (it may need to be done then) or could it be done at some other time like when the inventory is opened (so it only runs when the inventory is opened)...or in the inventory row callback (so it only runs when the row control is setup)?

Or you mentioned items getting deleted, if that is your purpose to monitor for deleted items it might be better to just watch for that using things like:
Lua Code:
  1. -- Items get destroyed by code:
  2. ZO_PreHook("DestroyItem", OnDestroyItem)
  3. -- Items get destroyed by dragging to main window:
  4. EVENT_MANAGER:RegisterForEvent(FilterIt.name, EVENT_MOUSE_REQUEST_DESTROY_ITEM, PreventMouseDragDestroy)
Instead of processing every slot update.
  Reply With Quote