Particles.CleanUp() called multiple times causes removeSelf() error

I probably blame myself for bad coding, but sometimes I just want to be sure that everything is deleted before moving on, so I’ve ended up calling Particles.CleanUp() more than once on a particular occasion.

Particle Candy obviously doesn’t like that, since it causes an error (not necessarily a crash), saying it can’t remove an object in the Emitter variable that doesn’t exist.

But, I made a small change in lib_particle_candy.lua that made the error go away, so you can call it multiple times without Particle Candy complaining.

In the bottom of the DeleteEmitter() function, change this:
[lua] – REMOVE EMITTER
Emitters[name].PTypes = nil
Emitters[name].PTypeIndex = nil
Emitters[name].PTypeSettings= nil
Emitters[name]:removeSelf()
Emitters[name] = nil
if debug then print ("–> Particles.DeleteEmitter(): DELETED EMITTER ‘"…name…"’") end[/lua]

to this:

[lua] – REMOVE EMITTER
Emitters[name].PTypes = nil
Emitters[name].PTypeIndex = nil
Emitters[name].PTypeSettings= nil
if Emitters[name] ~= nil then
if Emitters[name].numChildren ~= nil then
Emitters[name]:removeSelf()
end
end
Emitters[name] = nil
if debug then print ("–> Particles.DeleteEmitter(): DELETED EMITTER ‘"…name…"’") end[/lua]

Can anyone at X-Pressive verify that this doesn’t have any other adverse affects, and if so, can it be incorporated in a future build?
[import]uid: 6084 topic_id: 6479 reply_id: 306479[/import]

You should be able to call CleanUp() as many time as you like to. We couldn’t reproduce this issue (using a simple test code), so it could eventually be related to something else.

Could you send in a small sample code that reproduces this issue?

[import]uid: 10504 topic_id: 6479 reply_id: 22541[/import]

I don’t know if if X-pressive would approve, but I did make a change to get rid of the same problem.
I changed
V.Emitters[name]:removeSelf()
to
display:remove(V.Emitters[name])

The problem went away. I was getting the same error message, even though I was only calling Particles.CleanUp() only once.

Of course, I commented out the original line so I can easily reverse the change.

Jerry
[import]uid: 68376 topic_id: 6479 reply_id: 134498[/import]

Jerry, we have not been able to reproduce this error here, so could you please send us some sample code that demonstrates this issue? [import]uid: 10504 topic_id: 6479 reply_id: 134595[/import]

I don’t know if if X-pressive would approve, but I did make a change to get rid of the same problem.
I changed
V.Emitters[name]:removeSelf()
to
display:remove(V.Emitters[name])

The problem went away. I was getting the same error message, even though I was only calling Particles.CleanUp() only once.

Of course, I commented out the original line so I can easily reverse the change.

Jerry
[import]uid: 68376 topic_id: 6479 reply_id: 134498[/import]

Jerry, we have not been able to reproduce this error here, so could you please send us some sample code that demonstrates this issue? [import]uid: 10504 topic_id: 6479 reply_id: 134595[/import]