diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-09-15 10:48:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-09-15 11:08:38 +0300 |
commit | 69c551089b7793bada65295c5dcb3f5028c2e233 (patch) | |
tree | affdc4ceed389aaf4ef63c5568ef7bb7c8e5369f /source/blender/makesrna | |
parent | ac58663decabb25600862e7345377efe2da1ee92 (diff) |
Fix T79534: Python Operator.bl_translation_context ignored
The default value prevented it from being set on registration,
now only assign the default when the class doesn't define it.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index f248764eab9..3e8c469fc31 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1485,9 +1485,7 @@ static StructRNA *rna_Operator_register(Main *bmain, /* clear in case they are left unset */ temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = - temp_buffers.undo_group[0] = '\0'; - /* We have to set default op context! */ - strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + temp_buffers.undo_group[0] = temp_buffers.translation_context[0] = '\0'; /* validate the python class */ if (validate(&dummyotr, data, have_function) != 0) { @@ -1513,6 +1511,11 @@ static StructRNA *rna_Operator_register(Main *bmain, return NULL; } + /* We have to set default context if the class doesn't define it. */ + if (temp_buffers.translation_context[0] == '\0') { + STRNCPY(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + } + /* Convert foo.bar to FOO_OT_bar * allocate all strings at once. */ { @@ -1636,9 +1639,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, /* clear in case they are left unset */ temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = - temp_buffers.undo_group[0] = '\0'; - /* We have to set default op context! */ - strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + temp_buffers.undo_group[0] = temp_buffers.translation_context[0] = '\0'; /* validate the python class */ if (validate(&dummyotr, data, have_function) != 0) { @@ -1673,6 +1674,11 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, return NULL; } + /* We have to set default context if the class doesn't define it. */ + if (temp_buffers.translation_context[0] == '\0') { + STRNCPY(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + } + /* Convert foo.bar to FOO_OT_bar * allocate all strings at once. */ { |