[Bf-blender-cvs] [70fa2f6] master: Fix T47046: Exporting Max and Maya keymap throws RNA warnings in console.

Bastien Montagne noreply at git.blender.org
Thu Dec 31 14:57:58 CET 2015


Commit: 70fa2f69c9609c811522b6e0675ba7d8a2a74c08
Author: Bastien Montagne
Date:   Thu Dec 31 14:56:06 2015 +0100
Branches: master
https://developer.blender.org/rB70fa2f69c9609c811522b6e0675ba7d8a2a74c08

Fix T47046: Exporting Max and Maya keymap throws RNA warnings in console.

Totally harmless, but let's silence this bpyrna warning in case enum_items
is a DummyRNA_NULL_items, which is by definition empty...

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

M	source/blender/python/intern/bpy_rna.c

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

diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 47d89cd..cda1fc7 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1303,27 +1303,32 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
 				ret = PyUnicode_FromString(enum_item->identifier);
 			}
 			else {
-				const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
-
-				/* prefer not fail silently in case of api errors, maybe disable it later */
-				printf("RNA Warning: Current value \"%d\" "
-				       "matches no enum in '%s', '%s', '%s'\n",
-				       val, RNA_struct_identifier(ptr->type),
-				       ptr_name, RNA_property_identifier(prop));
-
-#if 0           /* gives python decoding errors while generating docs :( */
-				char error_str[256];
-				BLI_snprintf(error_str, sizeof(error_str),
-				             "RNA Warning: Current value \"%d\" "
-				             "matches no enum in '%s', '%s', '%s'",
-				             val, RNA_struct_identifier(ptr->type),
-				             ptr_name, RNA_property_identifier(prop));
-
-				PyErr_Warn(PyExc_RuntimeWarning, error_str);
+				RNA_property_enum_items(NULL, ptr, prop, &enum_item, NULL, &free);
+
+				/* Do not print warning in case of DummyRNA_NULL_items, this one will never match any value... */
+				if (enum_item != DummyRNA_NULL_items) {
+					const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
+
+					/* prefer not fail silently in case of api errors, maybe disable it later */
+					printf("RNA Warning: Current value \"%d\" "
+						   "matches no enum in '%s', '%s', '%s'\n",
+						   val, RNA_struct_identifier(ptr->type),
+						   ptr_name, RNA_property_identifier(prop));
+
+#if 0				/* gives python decoding errors while generating docs :( */
+					char error_str[256];
+					BLI_snprintf(error_str, sizeof(error_str),
+								 "RNA Warning: Current value \"%d\" "
+								 "matches no enum in '%s', '%s', '%s'",
+								 val, RNA_struct_identifier(ptr->type),
+								 ptr_name, RNA_property_identifier(prop));
+
+					PyErr_Warn(PyExc_RuntimeWarning, error_str);
 #endif
 
-				if (ptr_name)
-					MEM_freeN((void *)ptr_name);
+					if (ptr_name)
+						MEM_freeN((void *)ptr_name);
+				}
 
 				ret = PyUnicode_FromString("");
 			}




More information about the Bf-blender-cvs mailing list