Thread Tools Display Modes
05/26/14, 01:04 PM   #1
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
XML errors might appear after an addon has been disabeled

While testing on the EU client just about now, I noticed an odd bug - if a lua error would result in the XML running into a nil argument exception, that exception message will appear in the reload after the Addon has already been disabeled.

Wrote a more detailed bug report over in the ESO Forums, with code to reproduce and all:
http://forums.elderscrollsonline.com...n-is-disabeled
  Reply With Quote
05/26/14, 02:28 PM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
I have noticed this as well. I thought it was just something I was doing wrong when no one else mentioned anything about it. Maybe it is to do with how their reloadui works.
  Reply With Quote
05/27/14, 12:10 PM   #3
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
I'd be careful. I was messing around and created a ghost chat window, which kept giving me errors all over the place till I learned about the destroyContainer() function :P
  Reply With Quote
05/27/14, 01:38 PM   #4
stjobe
 
stjobe's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
On a possibly related note: If you have errors in your lua code, the game may throw errors even if that code never runs.

I had a faulty lua statement in SorcererHelper that threw errors on loading a non-sorcerer character, even though this code is the first that runs for the addon:

Lua Code:
  1. local function OnAddOnLoaded(eventCode, addOnName)
  2.     if (addOnName == "SorcererHelper") then
  3.         if GetUnitClassId("player") ~= 2 then
  4.             EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_ADD_ON_LOADED)
  5.             EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_PLAYER_ACTIVATED)
  6.             EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_ACTION_SLOT_ABILITY_SLOTTED)
  7.             EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_ACTIVE_WEAPON_PAIR_CHANGED)
  8.             EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_UNIT_ATTRIBUTE_VISUAL_ADDED)
  9.             EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_UNIT_ATTRIBUTE_VISUAL_REMOVED)
  10.             do return end
  11.         else
  12.             SH.SV = ZO_SavedVars:NewAccountWide("SorcererHelper_SavedVariables", 1, nil, SH.Defaults)
  13.             SH.CreateSettings()
  14.         end
  15.     end
  16. end
That "if GetUnitClassId("player") ~= 2" means that unless your character is a sorcerer, the addon will unregister all events and stop.

Even so, a bug in a function in code that never ran threw an "attempt to index a nil value" error. It stumped me for a while until I realized that it's a compile-time error.

I'm guessing the game loads and compiles all code during loading/reloading, and the bug I had gave a compile-time error - which was why it showed up even though the code itself never got called.
  Reply With Quote
05/27/14, 01:40 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
I haven't checked, but is GetUnitClassId() not available to call in the main chunk of your addon?
  Reply With Quote
05/27/14, 01:59 PM   #6
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
I would suspect anything Player related would not be accessible until the player is first activated.
  Reply With Quote
05/27/14, 02:23 PM   #7
stjobe
 
stjobe's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Originally Posted by Seerah View Post
I haven't checked, but is GetUnitClassId() not available to call in the main chunk of your addon?
Originally Posted by Xrystal View Post
I would suspect anything Player related would not be accessible until the player is first activated.
GetUnitClassId("player") can be called before EVENT_PLAYER_ACTIVATED, it works just fine. The function above runs on EVENT_ADD_ON_LOADED, but I also have several other initialization methods that run on EVENT_PLAYER_ACTIVATED.

I was merely suggesting that since the Lua code is compiled (and can therefore throw compile-time errors), perhaps something similar happens with the XML files for an addon - even if it is disabled.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » XML errors might appear after an addon has been disabeled


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