BetterBags - Gear First

BetterBags - Gear First

7.6k Downloads

Weird error in main.lua:91

rwygand opened this issue ยท 0 comments

commented

Line 91 of main.lua is getting a nil error evaluating b.title --

I worked around this by doing the following:

`function sort.SortSectionsGearAlphabetically(kind, a, b)
local shouldSort, sortResult = sort.SortSectionsByPriority(kind, a, b)
if shouldSort then return sortResult end

if a and b then
if a.title:GetText() == L:G("Recent Items") then return true end
if b.title:GetText() == L:G("Recent Items") then return false end

for _, gearType in pairs(const.GEAR_SECTION_ORDER) do
    if a.title:GetText() == L:G(gearType) then return true end
    if b.title:GetText() == L:G(gearType) then return false end
end

if string.find(a.title:GetText(), L:G("Gear") .. ":") then return true end
if string.find(b.title:GetText(), L:G("Gear") .. ":") then return false end

if a:GetFillWidth() then return false end
if b:GetFillWidth() then return true end

if a.title:GetText() == L:G("Free Space") then return false end
if b.title:GetText() == L:G("Free Space") then return true end

return stripColorCode(a.title:GetText()) < stripColorCode(b.title:GetText())
end

end`

So it looks like in some cases the b that is passed to the sort function is nil. This doesn't always happen -- but sometimes my bags just totally error on this.

Here's the backtrace

1x BetterBags_GearFirst/main.lua:99: attempt to index local 'b' (a nil value) [string "@BetterBags_GearFirst/main.lua"]:99: in function <BetterBags_GearFirst/main.lua:90> [string "=(tail call)"]: ? [string "=[C]"]: in function sort'
[string "@BetterBags/frames/grid.lua"]:242: in function Sort' [string "@BetterBags/views/gridview.lua"]:371: in function Render'
[string "@BetterBags/frames/bag.lua"]:316: in function Draw' [string "@BetterBags/core/init.lua"]:274: in function cb'
[string "@BetterBags/core/events.lua"]:49: in function <BetterBags/core/events.lua:47>
[string "=[C]"]: ?
[string "@BeQuiet/libs/Ace3/CallbackHandler-1.0-8/CallbackHandler-1.0.lua"]:19: in function <...ibs/Ace3/CallbackHandler-1.0/CallbackHandler-1.0.lua:15>
[string "@BeQuiet/libs/Ace3/CallbackHandler-1.0-8/CallbackHandler-1.0.lua"]:54: in function SendMessage' [string "@BetterBags/core/events.lua"]:206: in function SendMessage'
[string "@BetterBags/core/events.lua"]:224: in function <BetterBags/core/events.lua:223>

Locals:
kind = 0
a =

{
content =
{
}
frame = Frame {
}
title = Button {
}
maxItemsPerRow = 7
}
b = nil
shouldSort = false
sortResult = false
(for state) =
{
1 = "Head"
2 = "Neck"
3 = "Shoulder"
4 = "Back"
5 = "Chest"
6 = "Wrist"
7 = "Hands"
8 = "Waist"
9 = "Legs"
10 = "Feet"
11 = "Finger"
12 = "Trinket"
13 = "Main Hand"
14 = "Two-Hand"
15 = "One-Hand"
16 = "Off Hand"
17 = "Held In Off-hand"
18 = "Ranged"
19 = "Low iLvl"
}
(for control) = 1
_ = 1
gearType = "Head"
(*temporary) = "Gear: PvP"
(*temporary) = "Head"
(*temporary) =
{
data =
{
}
modules =
{
}
defaultModuleLibraries =
{
}
baseName = "BetterBags"
enabledState = true
locale = "enUS"
moduleName = "Localization"
defaultModuleState = true
name = "BetterBags_Localization"
orderedModules =
{
}
}
(*temporary) = "Head"
(*temporary) = "attempt to index local 'b' (a nil value)"
sort =
{
defaultModuleLibraries =
{
}
name = "BetterBags_Sort"
orderedModules =
{
}
enabledState = false
baseName = "BetterBags"
modules =
{
}
moduleName = "Sort"
defaultModuleState = true
}
L =
{
data =
{
}
modules =
{
}
defaultModuleLibraries =
{
}
baseName = "BetterBags"
enabledState = true
locale = "enUS"
moduleName = "Localization"
defaultModuleState = true
name = "BetterBags_Localization"
orderedModules =
{
}
}
const =
{
BANK_ONLY_BAGS =
{
}
BAG_KIND =
{
}
modules =
{
}
BANK_TAB =
{
}
BANK_BAGS =
{
}
BINDING_SCOPE =
{
}
BANK_ONLY_BAGS_LIST =
{
}
GEAR_SECTION_ORDER =
{
}
BAG_SUBTYPES =
{
}
DATABASE_DEFAULTS =
{
}
SECTION_SORT_TYPE =
{
}
baseName = "BetterBags"
INVENTORY_TYPE_TO_INVENTORY_SLOTS =
{
}
EQUIPMENT_SLOTS =
{
}
TRADESKILL_MAP =
{
}
name = "BetterBags_Constants"
BRIEF_EXPANSION_MAP =
{
}
orderedModules =
{
}
EXPANSION_MAP =
{
}
defaultModuleState = true
OFFSETS =
{
}
ITEM_QUALITY_COLOR =
{
}
BINDING_MAP =
{
}
ITEM_QUALITY_HIGHLIGHT =
{
}
BAG_SUBTYPE_TO_QUALITY =
{
}
ITEM_QUALITY_TO_ENUM =
{
}
EXPANSION_TYPE =
{
}
ITEM_SORT_TYPE =
{
}
BACKPACK_BAGS =
{
}
BAG_VIEW =
{
}
WINDOW_KIND =
{
}
defaultModuleLibraries =
{
}
ITEM_QUALITY_COLOR_LOW =
{
}
BACKPACK_ONLY_BAGS_LIST =
{
}
enabledState = false
BACKPACK_ONLY_REAGENT_BAGS =
{
}
ACCOUNT_BANK_BAGS =
{
}
GRID_COMPACT_STYLE =
{
}
MOVEMENT_FLOW =
{
}
REAGENTBANK_BAGS =
{
}
ITEM_BAG_FAMILY =
{
}
ITEM_QUALITY_COLOR_HIGH =
{
}
moduleName = "Constants"
BACKPACK_ONLY_BAGS =
{
}
}
`