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();