[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50713] trunk/blender/source/blender/ editors/interface/interface_handlers.c: fix for segfault when trying to link a sensor with an actuator from an object different than the active .
Dalai Felinto
dfelinto at gmail.com
Tue Sep 18 07:34:32 CEST 2012
Revision: 50713
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50713
Author: dfelinto
Date: 2012-09-18 05:34:31 +0000 (Tue, 18 Sep 2012)
Log Message:
-----------
fix for segfault when trying to link a sensor with an actuator from an object different than the active.
Campbell raised a preference on using direct C calls instead of WM_operator_name_call(). But since the original commit for 'smart controller' was already using it, this is something for a different commit
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface_handlers.c
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2012-09-18 04:55:52 UTC (rev 50712)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2012-09-18 05:34:31 UTC (rev 50713)
@@ -836,9 +836,16 @@
/* only works if the sensor and the actuator are from the same object */
if (!act_iter) return;
+
+ /* in case the linked controller is not the active one */
+ PointerRNA props_ptr, object_ptr;
+ RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
+
+ WM_operator_properties_create(&props_ptr, "LOGIC_OT_controller_add");
+ RNA_string_set(&props_ptr, "object", ob->id.name+2);
/* (3) add a new controller */
- if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) {
+ if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, &props_ptr) & OPERATOR_FINISHED) {
cont = (bController *)ob->controllers.last;
cont->type = CONT_LOGIC_AND; /* Quick fix to make sure we always have an AND controller. It might be nicer to make sure the operator gives us the right one though... */
@@ -858,6 +865,7 @@
MEM_freeN(tmp_but->link);
MEM_freeN(tmp_but);
}
+ WM_operator_properties_free(&props_ptr);
}
static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
More information about the Bf-blender-cvs
mailing list