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.
This commit is contained in:
Bastien Montagne 2021-07-19 15:59:26 +02:00
parent 132522cba8
commit bae1b64525
1 changed files with 8 additions and 9 deletions

View File

@ -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);