View Single Post
01-27-13, 06:09 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 01-27-13 at 10:19 PM.
  Reply With Quote