GetMerchantNumItems hangs on MERCHANT_UPDATE

#1 - July 4, 2012, 7:53 p.m.
Blizzard Post
I'm trying to update Swindler Preventer. I have code to scan tooltips of items available from a merchant.

When the data is not yet available, Swindler Preventer causes the game to freeze, blocking the data from becoming available and causing WoW to lock up. This doesn't happen on live (that I know of).

If the data is already available (for instance, turn off addon, log in, talk to vendor, log out, turn on addon, log in, talk to vendor again) the addon runs exactly as intended.

Here's a picture example of what I mean by the data 'not loaded yet.'

http://i49.tinypic.com/1z32xit.png

With some debug, I notice that the MERCHANT_SHOW event happens every time you talk to a vendor and open the window, but the MERCHANT_UPDATE event fires a whole lot of times when you talk to a vendor that you don't have data yet, and then the data displays. My addon is coded to begin tooltip scanning on either event, but either event will cause the 'freeze' if there is no data.

Is this the intended format for MERCHANT_SHOW and MERCHANT_UPDATE, that it fires before the data is actually available? If so, I need to put in some 'lag compensation' or something. Or is there an event I can listen for that indicates the data is now loaded?
Forum Avatar
Community Manager
#4 - July 5, 2012, 6:33 p.m.
Blizzard Post
This was due to GetMerchantNumItems() updating the filter (which is new), and the update of the filter was eventually calling MERCHANT_UPDATE again (rinse, repeat).

The base UI doesn’t get into this state because it sets self.update flag to handle it’s work on the next update loop.

But since too many things are causing MERCHANT_FILTER_ITEM_UPDATE to fire, its reasonable that this new filter system call a new event.

In an upcoming beta release you should see GetMerchantNumItems() will not fire MERCHANT_UPDATE instead it will fire MERCHANT_FILTER_ITEM_UPDATE event with arg1 being the item ID that was updated.
Forum Avatar
Community Manager
#6 - July 5, 2012, 9:57 p.m.
Blizzard Post
Thanks for the reply! I'm new, so that's slightly over my head. Which of the following statements are true? (Hope you don't mind newbie questions!)

A) If I look up what self.update does and what it means, it would create a better work-around than my current version of using OnUpdate (before the upcoming beta release you mentioned.)

B) In an upcoming beta release, my original code which calls GetMerchantNumItems() whenever MERCHANT_SHOW or MERCHANT_UPDATE fires will no longer freeze, and functionality should be similar to what it is on live. I don't need to code anything new, just be patient for that release.

C) In the new system, MERCHANT_FILTER_ITEM_UPDATE will fire when user or other input causes the current filter setting to possibly change resulting in a possible change of the items (and therefore possibly changing the number of items) displayed?

D) If C is true, then it might be a good idea to register/monitor the MERCHANT_FILTER_ITEM_UPDATE event too. Although to my knowledge recipes will display no matter what filter setting is used, in the future that could change and I like to think ahead. Which means that if I was monitoring that event in addition to the two I already monitor, would GetMerchantNumItems() freeze on the MERCHANT_FILTER_ITEM_UPDATE call, like it currently freezes on the MERCHANT_UPDATE call?

E) If D is true, should I still look into the self.update workaround anyway?

~

I've noticed that just about any addon that attempts to do something when a merchant is interacted with is causing a freeze (or in some cases, only a temporary freeze, or if data is already loaded, no freeze at all, like I mention in OP), not just mine. I haven't cracked open the code of the other addons yet to see if they're making the same GetMerchantNumItems() call that I am or if it's some other code that's causing a freeze. If B is true, I might wait to identify/bugfix those other addons until the release you mentioned.

Thanks again for the response!


A. Self.update better. True.

B. Be patient for release. True.

C. Possible change of item or number of items. True.

D. GetMerchantNumItems() freezes on the MERCHANT_FILTER_ITEM_UPDATE call. True.

E. Look into the self.update workaround? Yes.

F. Also correct.