ID:1551920
 
Descriptive Problem Summary:
Create an image that is called from a mob proc for instance- delete that mob before the image is deleted- and the image will persist indefinitely even if it is qued to be deleted.

Numbered Steps to Reproduce Problem:
See above
Code Snippet (if applicable) to Reproduce Problem:
HitEffect()
view(3)<<sound(pick('SoundEffects/Blow1.ogg','SoundEffects/Blow3.ogg'),0,0,0,10)
var/image/a=new
a.layer+=TOPDOWN_LAYER
a.icon='hits0.dmi'
a.icon_state=pick("1","2","3")//,"","","","")
a.loc=src.loc
range(3)<<a
animate(a,pixel_x=rand(-8,8),pixel_y=rand(16,32),time=8,easing=BOUNCE_EASING)
spawn(9)
del(a)


Expected Results:

Actual Results:
It works, the effect stays permanently however if the mob calling the proc is deleted or logs out.
Does the problem occur:
Every time? Or how often? Yes
In other games? Yes
In other user accounts? Yes
On other computers? Idk

When does the problem NOT occur?
Only under ideal conditions(when the atom calling the proc exists)
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Occuring since 504 for sure. Just upgraded to 506.
Workarounds:
Place an image creation proc on a global level and use that instead.
If I'm understanding you correctly, HitEffect() is a mob proc, and you're deleting the mob half-way through. When you delete a datum, all of its running procs are ended immediately. So in your case it never reaches the line to delete the image. If that is correct, this is intended behavior and not a bug.

If you want a proc to keep running after its src is deleted, you can set the src to null in the proc: src = null. Alternatively, like you mentioned, you can move this effect creation to a global proc, or another type.
I see, then what about when the player just happens to log out. Would the same apply?

*Edit* Maybe I misunderstood what you were saying,
You said to do this however correct?
procA()
set src = null

If so that ^^ doesn't work it throws errors so maybe I'm doing it wrong.

I'm aware of using src.loc=null, if that's what you mean- I was using that more liberally until I started encountering strange issues where things that should have been sent to null were not.
In response to Avidanimefan
Avidanimefan wrote:
I see, then what about when the player just happens to log out. Would the same apply?

If you delete the player's mob when they logout (most games do) then yes.

*Edit* Maybe I misunderstood what you were saying,
You said to do this however correct?
> procA()
> set src = null
>

If so that ^^ doesn't work it throws errors so maybe I'm doing it wrong.

I'm aware of using src.loc=null, if that's what you mean- I was using that more liberally until I started encountering strange issues where things that should have been sent to null were not.

Sorry, I should have been clearer. I didn't mean to use the set keyword, but rather to assign null to src:
mob/proc/procA()
src = null


Once you do that, the proc is detached from the object, and won't be killed off early if the object is deleted. It's a little unusual to do this, though. In your case, you would probably be better off creating some generic "effect" global proc that the mob can just call, or an effect type that it can use.
In response to DarkCampainger
Ah okay, I went with the later method, I only used that particular proc in a few places so it wasn't too much work to fix, but I do have another game where it would be much less work to use the 'src = null' method so I will use that too. Thanks!