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:
authorMitchell Stokes <mogurijin@gmail.com>2014-07-03 08:55:29 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-07-03 08:58:08 +0400
commit4af848e557fa8789ac0cc802d6479bd53145e1fd (patch)
treec39896ad450699b4b027f58c8b267675f9565bd1 /source/gameengine
parenteaf6f9fc5d7a4cdee6fd1ea7dac49ae7b2265ff2 (diff)
Fix T40923: An error from a python controller on a LibFreed object causes a crash
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp1
2 files changed, 6 insertions, 1 deletions
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 3a9e8ff0bbc..dbcbbea74a6 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -263,7 +263,11 @@ PyAttributeDef SCA_PythonController::Attributes[] = {
void SCA_PythonController::ErrorPrint(const char *error_msg)
{
- printf("%s - object '%s', controller '%s':\n", error_msg, GetParent()->GetName().Ptr(), GetName().Ptr());
+ // If GetParent() is NULL, then most likely the object this controller
+ // was attached to is gone (e.g., removed by LibFree()).
+ const char *obj_name = (GetParent()) ? GetParent()->GetName().ReadPtr() : "Unavailable";
+ const char *ctr_name = (GetParent()) ? GetName().ReadPtr() : "Unavailable";
+ printf("%s - object '%s', controller '%s':\n", error_msg, obj_name, ctr_name);
PyErr_Print();
/* Added in 2.48a, the last_traceback can reference Objects for example, increasing
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 0dfdb3d5f3b..3d71327828e 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -1038,6 +1038,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
!(itc==controllers.end());itc++)
{
m_logicmgr->RemoveController(*itc);
+ (*itc)->ReParent(NULL);
}
SCA_ActuatorList& actuators = newobj->GetActuators();