Page MenuHome

Fix T88499: Copy data path operator does not consider library affiliation
ClosedPublic

Authored by Philipp Oeser (lichtwerk) on May 27 2021, 2:41 PM.

Details

Summary

When using the operator ui.copy_data_path_button(full_path=True) (ctrl++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

Diff Detail

Repository
rB Blender
Branch
T88499 (branched from master)
Build Status
Buildable 14801
Build 14801: arc lint + arc unit

Event Timeline

Philipp Oeser (lichtwerk) requested review of this revision.May 27 2021, 2:41 PM
Philipp Oeser (lichtwerk) created this revision.
Campbell Barton (campbellbarton) requested changes to this revision.EditedMay 27 2021, 3:31 PM

General approach is correct,

  • id->lib->filepath should be escaped using BLI_str_escape.
  • The name token_filepath seems a bit odd? (being a *token* doesn't seem something worth emphasizing?) prefer lib_filepath or id_lib_filepath.
  • There is no need to allocate the token path, as the source buffer is a fixed size. This will simplify escaping too. Then the result of BLI_snprintf can be it was before.
This revision now requires changes to proceed.May 27 2021, 3:31 PM

escape the string and dont use "token" in variable name (was only there since this string included the ', ')

source/blender/makesrna/intern/rna_access.c
6123–6139

Memory allocation can be avoided here.

avoid memory allocation (thx holding my hand Campbell)

Philipp Oeser (lichtwerk) marked an inline comment as done.May 27 2021, 5:02 PM
This revision is now accepted and ready to land.May 27 2021, 5:14 PM