Well, that error is certainly interesting, because it names line 585, which is a blank line in the file you posted...
Anyway, I don't see anything immediately obvious, and don't have time right now to comb through everything to figure out what's going wrong, but I'd suggest using a more robust recycling system for your textures.
Code:
local textures = {} -- textures in use
local GetTexture, FreeTexture
do
local pool = {}
function GetTexture(parent)
local texture = next(pool)
if texture then
pool[texture] = nil
texture:SetParent(texture)
return texture
else
return parent:CreateTexture()
end
end
function FreeTexture(texture)
texture:ClearAllPoints()
texture:SetParent(nil) -- might need to use UIParent instead of nil here
texture:SetTexture(nil)
pool[texture] = true
end
end
Mixing used and unused textures in the same table seems like a recipe for trouble.
Also, when you clear the texture, don't forget to nil out the reference to it, eg:
Code:
bar.segments[firstVisible].tick = ns:freeTempTexture(bar.segments[firstVisible].tick)
I didn't look very far, but this may be related to your problem.