[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35136] trunk/blender/source/blender: internal operator/wm/macro function: dont crash if operators are not found (warning will be printed).
Campbell Barton
ideasman42 at gmail.com
Fri Feb 25 05:15:45 CET 2011
Revision: 35136
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35136
Author: campbellbarton
Date: 2011-02-25 04:15:45 +0000 (Fri, 25 Feb 2011)
Log Message:
-----------
internal operator/wm/macro function: dont crash if operators are not found (warning will be printed).
Modified Paths:
--------------
trunk/blender/source/blender/editors/armature/armature_ops.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_ops.c 2011-02-25 04:02:58 UTC (rev 35135)
+++ trunk/blender/source/blender/editors/armature/armature_ops.c 2011-02-25 04:15:45 UTC (rev 35136)
@@ -166,23 +166,29 @@
wmOperatorTypeMacro *otmacro;
ot= WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
- WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
- otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ if(ot) {
+ WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
+ otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+ }
ot= WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER);
- otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
- RNA_enum_set(otmacro->ptr, "forked", 0);
- otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ if(ot) {
+ otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
+ RNA_enum_set(otmacro->ptr, "forked", 0);
+ otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+ }
// XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate?
// that would require fixing a properties bug 19733
ot= WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", OPTYPE_UNDO|OPTYPE_REGISTER);
- otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
- RNA_enum_set(otmacro->ptr, "forked", 1);
- otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ if(ot) {
+ otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
+ RNA_enum_set(otmacro->ptr, "forked", 1);
+ otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+ }
}
void ED_keymap_armature(wmKeyConfig *keyconf)
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2011-02-25 04:02:58 UTC (rev 35135)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2011-02-25 04:15:45 UTC (rev 35136)
@@ -382,21 +382,24 @@
wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
{
wmOperatorTypeMacro *otmacro= MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro");
-
+
BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME);
/* do this on first use, since operatordefinitions might have been not done yet */
WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname);
WM_operator_properties_sanitize(otmacro->ptr, 1);
-
+
BLI_addtail(&ot->macro, otmacro);
{
+ /* operator should always be found but in the event its not. dont segfault */
wmOperatorType *otsub = WM_operatortype_find(idname, 0);
- RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna,
- otsub->name, otsub->description);
+ if(otsub) {
+ RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna,
+ otsub->name, otsub->description);
+ }
}
-
+
return otmacro;
}
More information about the Bf-blender-cvs
mailing list