prime31 / Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
MIT License
1.76k stars 355 forks source link

Check if scene is null before destroying entity #768

Closed xThuby closed 1 year ago

xThuby commented 1 year ago

I ran into an issue where a schedule destruction of an entity was causing a crash if the scene changed before the scheduled event fired. This smells a little bit fishy, cause I would expect the entity to get destroyed on scene changed, or at least caught by the GC, and thus give an error that the target of the destruction is null. But instead I'm getting an exception saying that the Scene is null, implying that the entity is sticking around after a scene change. If there's an underlying problem here then this PR does not fix that, but it does fix the one specific issue I had.