[Bf-blender-cvs] [16c75cf] master: Fix T38654: Using a non-camera object for the SetCamera Scene Actuator causes a segfault.
Mitchell Stokes
noreply at git.blender.org
Mon Feb 17 23:50:13 CET 2014
Commit: 16c75cf594a92b232e46f922d644ac0a70088bad
Author: Mitchell Stokes
Date: Mon Feb 17 14:35:09 2014 -0800
https://developer.blender.org/rB16c75cf594a92b232e46f922d644ac0a70088bad
Fix T38654: Using a non-camera object for the SetCamera Scene Actuator causes a segfault.
Non-camera objects are not supported as cameras, and trying to use them
just causes memory errors (some bad typecasts are involved). When converting
a Scene Actuator, only use the object as a camera if it is actually a camera.
Also, the logic brick UI now filters for camera objects, which should help
avoid confusion.
===================================================================
M source/blender/makesrna/intern/rna_actuator.c
M source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index 7747c5e..e5545f9 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -1479,10 +1479,10 @@ static void rna_def_scene_actuator(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_type_items);
RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_update(prop, NC_LOGIC, NULL);
-
- /*XXX filter only camera objects */
+
prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
+ RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Camera Object", "Set this Camera (leave empty to refer to self object)");
RNA_def_property_update(prop, NC_LOGIC, NULL);
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 26401fc..725e981 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -758,7 +758,9 @@ void BL_ConvertActuators(const char* maggiename,
mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
if (sceneact->camera)
{
- cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
+ KX_GameObject *tmp = converter->FindGameObject(sceneact->camera);
+ if (tmp && tmp->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
+ cam = (KX_Camera*)tmp;
}
break;
case ACT_SCENE_RESTART:
More information about the Bf-blender-cvs
mailing list