diff options
author | Bastien Montagne <bastien@blender.org> | 2022-10-14 19:35:28 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-10-14 19:35:28 +0300 |
commit | 9e77f5f17fcadf12316ed855ac47abf32592d84f (patch) | |
tree | 6efdb6ce7468f6095822566202ee85a9c9f3ffdd /source/blender/makesrna/intern | |
parent | 4112f0241b20c9b0904bec4e69aecf2af1844a86 (diff) |
Fix T101803: Max length Operator bl_idname is truncated 1 character.
There were quite a few issues here:
* Bad usage of nagic number leading to confusing code
* Forgetting to take into accoun final `NULL` char
* RNA code thinkin `bl_idname` is python version, when it is actually
BL/C version.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 7fd590005fd..5b5544120a1 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1644,12 +1644,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, return NULL; } - if (strlen(identifier) >= sizeof(dummyop.idname)) { - BKE_reportf(reports, - RPT_ERROR, - "Registering operator class: '%s' is too long, maximum length is %d", - identifier, - (int)sizeof(dummyop.idname)); + if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) { return NULL; } @@ -1661,10 +1656,6 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, } } - if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) { - return NULL; - } - char idname_conv[sizeof(dummyop.idname)]; WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */ @@ -1867,8 +1858,9 @@ static void rna_def_operator_common(StructRNA *srna) /* Registration */ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); - /* Without setting the length the pointer size would be used. -3 because `.` -> `_OT_`. */ - RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME - 3); + /* String stored here is the 'BL' identifier (`OPMODULE_OT_my_op`), + * not the 'python' identifier (`opmodule.my_op`). */ + RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set"); // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER); |