# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1271899124 0 # Node ID 78a1eb57c0740f7d1a753b6c2d3c4c837ef87874 # Parent afde89c1d50b6867d06be7bd69dae96bdf3b7a53 Changed the way instances get deleted from the scene. Instances now get removed at the end of the frame as opposed to after their explosion action is complete. The old way was causing the odd segfault because the instance was being removed before FIFE was finished with it. diff -r afde89c1d50b -r 78a1eb57c074 demos/shooter/scripts/common/baseobject.py --- a/demos/shooter/scripts/common/baseobject.py Wed Apr 21 18:20:13 2010 +0000 +++ b/demos/shooter/scripts/common/baseobject.py Thu Apr 22 01:18:44 2010 +0000 @@ -112,10 +112,10 @@ self._velocity.y += (norm.y * (self._scene.timedelta/1000.0))/self._yscale def removeFromScene(self): - self._scene.removeObjectFromScene(self) - if self._instance: - self._layer.deleteInstance(self._instance) - self._instance = None + self._scene.queueObjectForRemoval(self) +# if self._instance: +# self._layer.deleteInstance(self._instance) +# self._instance = None def _isRunning(self): return self._running diff -r afde89c1d50b -r 78a1eb57c074 demos/shooter/scripts/scene.py --- a/demos/shooter/scripts/scene.py Wed Apr 21 18:20:13 2010 +0000 +++ b/demos/shooter/scripts/scene.py Thu Apr 22 01:18:44 2010 +0000 @@ -52,6 +52,7 @@ self._player = None self._projectiles = list() + self._objectstodelete = list() self._maxnodes = 128 self._xscale = 0 @@ -172,6 +173,9 @@ def endLevel(self): self._world.endLevel() + def queueObjectForRemoval(self, obj): + self._objectstodelete.append(obj) + def removeAllProjectiles(self): projtodelete = list() for p in self._projectiles: @@ -219,6 +223,8 @@ for node in self._nodes: if obj in node.spaceobjects: node.spaceobjects.remove(obj) + self._layer.deleteInstance(obj.instance) + obj.instance = None return def attachCamera(self, cam): @@ -318,6 +324,13 @@ if p in self._projectiles: p.destroy() self._projectiles.remove(p) + + for obj in self._objectstodelete: + self.removeObjectFromScene(obj) + self._layer.deleteInstance(obj.instance) + obj.instance = None + + self._objectstodelete = list() def _getPlayer(self):