LibDropdown-1.0

LibDropdown-1.0

153k Downloads

Error when addons include different versions of LibDropDown

timzwiebel opened this issue ยท 1 comments

commented

When two addons include different versions of LibDropDown, it results in attempts to call a nil value.

Real Example:
Hemlock uses version 1 of LibDropDown and Recount uses version 2. This results in the following error when clicking the fights menu in Recount (or right clicking the poison icons in Hemlock):

Error occured in: Global
Message: ...\LibDropDown-1.0\LibDropDown-1.0\LibDropdown-1.0.lua line 1015:
   attempt to call upvalue 'new' (a nil value)
Debug:
   ...\LibDropDown-1.0\LibDropDown-1.0\LibDropdown-1.0.lua:1015: OpenAce3Menu()
   ...\LibDropDown-1.0\LibDropDown-1.0\LibDropdown-1.0.lua:1010: OpenAce3Menu()
   Recount\GUI_Main.lua:1368: OpenFightDropDown()
   Recount\GUI_Main.lua:812:
      Recount\GUI_Main.lua:811
AddOns:
  Swatter, v8.2.6377 (SwimmingSeadragon)
  Hemlock, v1.1.3
  Recount, vv1.13.5c
  BlizRuntimeLib_enUS v1.13.5.11305 <none>
  (ck=7b)

Cause:
I believe the cause is due to lines 61-87. If the addon with the newer version of LibDropDown is loaded first, there is no issue because LibStub:NewLibrary returns nil and the rest of the file is not executed. However, if the addon with the older version loads first, the local variables new and del are never initialized (they are nil), so invoking them later in the code will cause errors (like the one in the example). Those lines should be rewritten like this:

local new, del = lib.new, lib.del
if not lib.new then
	<truncated...>  -- define new and del here
	lib.new, lib.del = new, del
end

The 2 major changes are 1) initialize new and del to lib.new and lib.del respectively, and 2) remove newHash and newSet since they appear to not be used.

commented

Makes sense. Making this change.