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:
authorPhilipp Oeser <info@graphics-engineer.com>2021-05-27 15:36:18 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2021-05-28 12:06:55 +0300
commit63e50cf265d6f17785ffdf0d0a7220237b054050 (patch)
treecb71a85b089cf3c23c63d3bee06c5b67a2f2d02f
parent3ec57ce6c7fcd3aa59c9b60139321c11f73fb7f7 (diff)
Fix T88499: Copy data path operator does not consider library affiliation
When using the operator `ui.copy_data_path_button(full_path=True)` ({key ctrl shift Alt C} on hover) the copied path does not consider the library origin. That means that when there is a name clash the data path is not accurate and refers to the local item instead. This patch adds the library (if the ID is linked) of the returned string from RNA_path_full_ID_py. bpy.data.objects["Cube", "//library.blend"] instead of bpy.data.objects["Cube"] note: parsing this happens in pyrna_prop_collection_subscript_str_lib_pair_ptr Maniphest Tasks: T88499 Differential Revision: https://developer.blender.org/D11412
-rw-r--r--source/blender/makesrna/intern/rna_access.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 150a455f1c7..948fef1b51e 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -6115,13 +6115,25 @@ char *RNA_path_full_ID_py(Main *bmain, ID *id)
path = "";
}
- char id_esc[(sizeof(id->name) - 2) * 2];
+ char lib_filepath_esc[(sizeof(id->lib->filepath) * 2) + 4];
+ if (id->lib != NULL) {
+ int ofs = 0;
+ memcpy(lib_filepath_esc, ", \"", 3);
+ ofs += 3;
+ ofs += BLI_str_escape(lib_filepath_esc + ofs, id->lib->filepath, sizeof(lib_filepath_esc));
+ memcpy(lib_filepath_esc + ofs, "\"", 2);
+ }
+ else {
+ lib_filepath_esc[0] = '\0';
+ }
+ char id_esc[(sizeof(id->name) - 2) * 2];
BLI_str_escape(id_esc, id->name + 2, sizeof(id_esc));
- return BLI_sprintfN("bpy.data.%s[\"%s\"]%s%s",
+ return BLI_sprintfN("bpy.data.%s[\"%s\"%s]%s%s",
BKE_idtype_idcode_to_name_plural(GS(id->name)),
id_esc,
+ lib_filepath_esc,
path[0] ? "." : "",
path);
}