[Bf-blender-cvs] [63e50cf265d] master: Fix T88499: Copy data path operator does not consider library affiliation

Philipp Oeser noreply at git.blender.org
Fri May 28 11:17:25 CEST 2021


Commit: 63e50cf265d6f17785ffdf0d0a7220237b054050
Author: Philipp Oeser
Date:   Thu May 27 14:36:18 2021 +0200
Branches: master
https://developer.blender.org/rB63e50cf265d6f17785ffdf0d0a7220237b054050

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

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

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

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

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);
 }



More information about the Bf-blender-cvs mailing list