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>2019-10-04 13:24:26 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-10-04 13:27:10 +0300
commit19b0f69009501df8b153d33ffcf6977019d53291 (patch)
treeb957fe6ba1d4887fa6fb2bbc75b3f35dbb26775f /source/blender/python
parentba10cd49220a778014fa2e77eff45c32ca106fbe (diff)
Fix T70481: Segfault printing 'private data' evaluated IDs.
This commit solves the bug itself (code was broken when real_id owner of the private data ID could not be found), and generates a more sensible representation for all evaluated IDs, makes no sense to display them as being part of `bpy.data....`!
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 45a7d2dacd1..d13393280d0 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -70,6 +70,8 @@
/* Only for types. */
#include "BKE_node.h"
+#include "DEG_depsgraph_query.h"
+
#include "../generic/idprop_py_api.h" /* For IDprop lookups. */
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
@@ -918,7 +920,10 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
tmp_str = PyUnicode_FromString(id->name + 2);
- if (RNA_struct_is_ID(self->ptr.type) && (id->flag & LIB_PRIVATE_DATA) == 0) {
+ if (DEG_get_original_id(id) != id) {
+ ret = PyUnicode_FromFormat("Evaluated %s %R", BKE_idcode_to_name(GS(id->name)), tmp_str);
+ }
+ else if (RNA_struct_is_ID(self->ptr.type) && (id->flag & LIB_PRIVATE_DATA) == 0) {
ret = PyUnicode_FromFormat(
"bpy.data.%s[%R]", BKE_idcode_to_name_plural(GS(id->name)), tmp_str);
}
@@ -926,14 +931,25 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
const char *path;
ID *real_id = NULL;
path = RNA_path_from_real_ID_to_struct(G_MAIN, &self->ptr, &real_id);
- if (path) {
- if (real_id != id) {
+ if (path != NULL) {
+ /* real_id may be NULL in some cases, although the only valid one is evaluated data,
+ * which should have been catched already above.
+ * So assert, but handle it without crashing for release builds. */
+ BLI_assert(real_id != NULL);
+
+ if (real_id != NULL) {
Py_DECREF(tmp_str);
tmp_str = PyUnicode_FromString(real_id->name + 2);
+ ret = PyUnicode_FromFormat(
+ "bpy.data.%s[%R].%s", BKE_idcode_to_name_plural(GS(real_id->name)), tmp_str, path);
+ }
+ else {
+ /* Can't find the path, print something useful as a fallback. */
+ ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
+ BKE_idcode_to_name_plural(GS(id->name)),
+ tmp_str,
+ RNA_struct_identifier(self->ptr.type));
}
- ret = PyUnicode_FromFormat(
- "bpy.data.%s[%R].%s", BKE_idcode_to_name_plural(GS(real_id->name)), tmp_str, path);
-
MEM_freeN((void *)path);
}
else {