Hi there!
I have a perplexing problem. I have a local table, textures, which is indexed by the texture object/widget. The value at a given index is true if the texture is in use, and false if not. (to store previously created textures to save work)
Now the perplexing part is that somewhere the texture is losing it's classification or whatever as a widget. However, any manually set values inside the widgets table stay. I have absolutely no clue what's causing this to happen and I was wondering if anyone else has had this happen to them.
Below is my get and free texture functions.
Code:
local numTexs = 0
function ns:getTempTexture(parent)
local texture
for tex, used in pairs(textures) do
if not texture and not used then
texture = tex
textures[texture] = true
--print("Gave premade texture ", texture.name)
break
end
end
if not texture then -- need to make one
texture = ns.frame:CreateTexture("Texture"..(numTexs))
texture.name = "Texture"..(numTexs)
textures[texture] = true
--print("Made new texture ", texture.name)
end
numTexs = numTexs + 1
texture:Hide()
texture:SetParent(parent or ns.frame)
return texture
end
function ns:freeTempTexture(texture)
if texture == nil then return end
if textures[texture] then -- in use
textures[texture] = false -- Free the texture up
--print("Freed up texture ", texture.name)
texture:Hide() -- Hide it.
texture:ClearAllPoints() -- Unset it's location settings
return
end
print("Attempting to remove a non used texture?")
end
Now to be more specific, if I do a /dump on the textures table after a few textures have already been created, I get something like
Code:
textures = {
[Texture:Texture0] = false,
[Texture:Texture1] = false,
[Texture:Texture2] = false,
}
which is perfectly fine. However, when I call getTempTexture() after this point, I get an error that Hide() can't be performed on a non-widget. When I then dump out the textures table again, instead I get
Code:
textures = {
[{name="Texture0"}] = false,
[Texture:Texture1] = false,
[Texture:Texture2] = false,
}
Something is causing the object to lose it's texture properties but keep set values in the table, and I have absolutely no clue what it is.
Thoughts? Thanks!