bdilly pushed a commit to branch master.

http://git.enlightenment.org/games/eskiss.git/commit/?id=f47833f6c5315df510ef7d2a34acd4697d568775

commit f47833f6c5315df510ef7d2a34acd4697d568775
Author: Bruno Dilly <bdi...@profusion.mobi>
Date:   Mon Oct 17 15:14:47 2016 -0200

    Fix abortion on bodies deletion
    
    Fix issues when deleting static bodies (when you change levels
    or presse menu option).
    
    It was leading to the following error:
    Aborting due to Chipmunk error: Cannot remove a body that was not
      added to the space. (Removed twice maybe?)
    Failed condition: cpSpaceContainsBody(space, body)
    Source:/build/buildd/chipmunk-6.1.5/src/cpSpace.c:403
    
    Static bodies shouldn't be added to space on Chipmunk, and that's correct.
    But for some reason we're trying to remove them from space under
    certain circustances.
---
 src/bin/physic_object.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/bin/physic_object.c b/src/bin/physic_object.c
index 1f365e5..387768a 100644
--- a/src/bin/physic_object.c
+++ b/src/bin/physic_object.c
@@ -520,7 +520,10 @@ void physic_object_del(PhysicObject *pobj)
                 evas_object_del(obj);
 
         //remove body
-        cpSpaceRemoveBody(space, pobj->body);
+        // But don't try to remove static bodies, since they're not
+        // added to space (otherwise they would be simulated).
+        if (!pobj->static_body)
+                cpSpaceRemoveBody(space, pobj->body);
         cpBodyFree(pobj->body);
 
         physic_objects = eina_list_remove(physic_objects, pobj);

-- 


Reply via email to