diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-23 07:59:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-23 08:02:21 +0300 |
commit | 1e60ac33949ae533857fc6a48ce5fbc2402dd060 (patch) | |
tree | f3653899ca70880ec4c5b8438c15d16e85e60147 /source/blender/makesrna/intern/rna_wm.c | |
parent | 4761dea573f6fa9a57150596098c17f723d3a49f (diff) |
RNA: report error on struct naming collision
Fixes T52463, error instead of crash.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 4aee03025f6..a7afc405048 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1147,6 +1147,16 @@ static StructRNA *rna_Operator_register( if (validate(&dummyotr, data, have_function) != 0) return NULL; + /* check if we have registered this operator type before, and remove it */ + { + wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true); + if (ot && ot->ext.srna) + rna_Operator_unregister(bmain, ot->ext.srna); + } + if (!RNA_struct_available_or_report(reports, identifier)) { + return NULL; + } + { /* convert foo.bar to FOO_OT_bar * allocate the description and the idname in 1 go */ @@ -1214,13 +1224,6 @@ static StructRNA *rna_Operator_register( } } - /* check if we have registered this operator type before, and remove it */ - { - wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true); - if (ot && ot->ext.srna) - rna_Operator_unregister(bmain, ot->ext.srna); - } - /* XXX, this doubles up with the operator name [#29666] * for now just remove from dir(bpy.types) */ @@ -1323,6 +1326,16 @@ static StructRNA *rna_MacroOperator_register( return NULL; } + /* check if we have registered this operator type before, and remove it */ + { + wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true); + if (ot && ot->ext.srna) + rna_Operator_unregister(bmain, ot->ext.srna); + } + if (!RNA_struct_available_or_report(reports, identifier)) { + return NULL; + } + { /* convert foo.bar to FOO_OT_bar * allocate the description and the idname in 1 go */ const uint idname_len = strlen(temp_buffers.idname) + 4; @@ -1349,13 +1362,6 @@ static StructRNA *rna_MacroOperator_register( dummyot.undo_group = ch; } - /* check if we have registered this operator type before, and remove it */ - { - wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true); - if (ot && ot->ext.srna) - rna_Operator_unregister(bmain, ot->ext.srna); - } - /* XXX, this doubles up with the operator name [#29666] * for now just remove from dir(bpy.types) */ |