Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-04-15 14:57:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-15 14:57:28 +0400
commite8f4d9322112e64677df11ba834a26159874b332 (patch)
treea26e20a97d0c6b79c06da995b6b64c01a0fb057c /source/gameengine/PyDoc
parent19c869ab64a0e14727217c7d221e03d32a614132 (diff)
Disable using KX_GameObjects in python that have been removed from the scene (zombie objects) by raising a RuntimeError when accessing methods, attributes or passing to a function.
Common cases of this are when python references an object from the AddObject actuator that has ended, or a scene has been loaded and the old objects freed. This means some scripts will raise errors now in certain cases but better give the error early rather then failing silently with strange hard to track down behavior & crashes. Added "isValid" attribute for checking objects are in a scene. At the moment it uses the SceneGraph Node to check of the objects valid but it might be better to do this in a more generic way so scenes, meshes etc also have this check.
Diffstat (limited to 'source/gameengine/PyDoc')
-rw-r--r--source/gameengine/PyDoc/KX_GameObject.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py
index 44b84d44d8d..4aa9de2fe86 100644
--- a/source/gameengine/PyDoc/KX_GameObject.py
+++ b/source/gameengine/PyDoc/KX_GameObject.py
@@ -12,6 +12,7 @@ class KX_GameObject: # (SCA_IObject)
All game objects are derived from this class.
Properties assigned to game objects are accessible as attributes of this class.
+ - note: Calling ANY method or attribute on an object that has been removed from a scene will raise a RuntimeError, if an object may have been removed since last accessing it use the L{isValid} attribute to check.
@ivar name: The object's name. (Read only)
- note: Currently (Blender 2.49) the prefix "OB" is added to all objects name. This may change in blender 2.5.
@@ -63,6 +64,8 @@ class KX_GameObject: # (SCA_IObject)
- note: This attribute is experemental and may be removed (but probably wont be).
- note: Changes to this list will not update the KX_GameObject.
@type actuators: list
+ @ivar isValid: Retuerns fails when the object has been removed from the scene and can no longer be used.
+ @type isValid: bool
"""
def endObject(visible):
"""