Severe bug in Labels (SOLVED)

Seems like the newly added Labels doesn’t handle go.delete very well.
When creating several gameobjects with labels and dynamically set text on them and then delete them, all labels seems to freak out and pick random strings from memory

Below is a test where I create an array of gameobjects, each with a label on them.
Each label is then set to their own text (number in this case).
When deleting one gameobject / second all the other labels goes havoc.

Main script:
function init(self)
self.timer = 1
self.tbl = {}
for i = 1,10 do
for ii = 1,10 do
table.insert(self.tbl, factory.create("#factory", vmath.vector3(ii30,i30,0),nil, {nr = (ii-1)*10+i-1}))
end
end

    for i,v in ipairs(self.tbl) do
    	local url = msg.url(v)
    	url.fragment = "label"
    	label.set_text(url, tostring(i))
    end
end

function update(self, dt)
	self.timer = self.timer - dt
	if self.timer < 0 then
		local t = table.remove(self.tbl)
		go.delete(t)
		self.timer = 1
	end
end

(no script on gameobject)
Results:

1 Like

Hello @AJirenius!

This was reported earlier this sprint and has been fixed by @Mathias_Westerdahl. You can test the beta branch at http://d.defold.com/beta, it should be working there and will be part of the next stable release that is scheduled to be released on Monday.

3 Likes

Hi @jakob.pogulis . As always, you’re awesome!
Worked like a charm.

3 Likes

This was fixed in Defold 1.2.94. DEF-2303.

2 Likes