[Bf-blender-cvs] [69c551089b7] master: Fix T79534: Python Operator.bl_translation_context ignored

Campbell Barton noreply at git.blender.org
Tue Sep 15 10:09:15 CEST 2020


Commit: 69c551089b7793bada65295c5dcb3f5028c2e233
Author: Campbell Barton
Date:   Tue Sep 15 17:48:12 2020 +1000
Branches: master
https://developer.blender.org/rB69c551089b7793bada65295c5dcb3f5028c2e233

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.

===================================================================

M	source/blender/makesrna/intern/rna_wm.c

===================================================================

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. */
   {



More information about the Bf-blender-cvs mailing list