Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-07-19 16:59:26 +0300
committerBastien Montagne <bastien@blender.org>2021-07-19 17:05:24 +0300
commitbae1b64525237617ef5c3ab30acfd042e8eca9eb (patch)
treeecc0542cd19a93924b4172e9cc0bcac7844d5106
parent132522cba894954406877eba9067b9be06c60cde (diff)
Fix broken 'undocumented' case in registration of Macro opertators.
Code dealing with macro operators missing description field was slightly different than the one from Operator registration. This lead to invalid memory accesses in some python introspection cases like the i18n messages extraction code in `bl_i18n_utils` module.
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index e17d5a9ae70..39435721d1a 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -498,12 +498,11 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname,
ot->cancel = wm_macro_cancel;
ot->poll = NULL;
- if (!ot->description) {
- /* XXX All ops should have a description but for now allow them not to. */
- ot->description = UNDOCUMENTED_OPERATOR_TIP;
- }
+ /* XXX All ops should have a description but for now allow them not to. */
+ BLI_assert((ot->description == NULL) || (ot->description[0]));
- RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
+ RNA_def_struct_ui_text(
+ ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
/* Use i18n context from rna_ext.srna if possible (py operators). */
i18n_context = ot->rna_ext.srna ? RNA_struct_translation_context(ot->rna_ext.srna) :
@@ -530,16 +529,16 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *),
ot->cancel = wm_macro_cancel;
ot->poll = NULL;
- if (!ot->description) {
- ot->description = UNDOCUMENTED_OPERATOR_TIP;
- }
+ /* XXX All ops should have a description but for now allow them not to. */
+ BLI_assert((ot->description == NULL) || (ot->description[0]));
/* Set the default i18n context now, so that opfunc can redefine it if needed! */
RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
opfunc(ot, userdata);
- RNA_def_struct_ui_text(ot->srna, ot->name, ot->description);
+ RNA_def_struct_ui_text(
+ ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);