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 <montagne29@wanadoo.fr>2015-12-31 16:56:06 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-12-31 16:57:48 +0300
commit70fa2f69c9609c811522b6e0675ba7d8a2a74c08 (patch)
treeb55ab7a29a2833ac6752862886a90f9ed9acd890
parent702372f6c5c2ef8db0324df4eb83d9aee1eaebc3 (diff)
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...
-rw-r--r--source/blender/python/intern/bpy_rna.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 47d89cd43ae..cda1fc708c2 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("");
}