diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index e0adc391a24..7c4ee7b6649 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -58,7 +58,6 @@ #include "WM_types.h" #include "ED_paint.h" -#include "ED_object.h" /* only for UI_OT_editsource */ #include "ED_screen.h" @@ -289,48 +288,45 @@ bool UI_context_copy_to_selected_list( } else if (OB_DATA_SUPPORT_ID(GS(id->name))) { /* check we're using the active object */ + const short id_code = GS(id->name); + ListBase lb = CTX_data_collection_get(C, "selected_editable_objects"); + char *path = RNA_path_from_ID_to_property(ptr, prop); - Object *ob = ED_object_context(C); - if (ob && ob->data == id) { - const short id_code = GS(id->name); - ListBase lb = CTX_data_collection_get(C, "selected_editable_objects"); - char *path = RNA_path_from_ID_to_property(ptr, prop); + /* de-duplicate obdata */ + if (!BLI_listbase_is_empty(&lb)) { + CollectionPointerLink *link, *link_next; - if (path) { - char *path_tmp; - path_tmp = path; - path = BLI_sprintfN("data%s%s", path[0] == '[' ? "" : ".", path); - MEM_freeN(path_tmp); - } - - /* de-duplicate obdata */ - if (!BLI_listbase_is_empty(&lb)) { - CollectionPointerLink *link, *link_next; - - for (link = lb.first; link; link = link->next) { - Object *ob = link->ptr.id.data; - if (ob->data) { - ID *id = ob->data; - id->flag |= LIB_DOIT; - } - } - - for (link = lb.first; link; link = link_next) { - Object *ob = link->ptr.id.data; - ID *id = ob->data; - link_next = link->next; - if ((id == NULL) || (id->flag & LIB_DOIT) == 0 || (GS(id->name) != id_code)) { - BLI_remlink(&lb, link); - MEM_freeN(link); - } - id->flag &= ~LIB_DOIT; + for (link = lb.first; link; link = link->next) { + Object *ob = link->ptr.id.data; + if (ob->data) { + ID *id_data = ob->data; + id_data->flag |= LIB_DOIT; } } - *r_lb = lb; - *r_path = path; + for (link = lb.first; link; link = link_next) { + Object *ob = link->ptr.id.data; + ID *id_data = ob->data; + link_next = link->next; + + if ((id_data == NULL) || + (id_data->flag & LIB_DOIT) == 0 || + (id_data->lib) || + (GS(id_data->name) != id_code)) + { + BLI_remlink(&lb, link); + MEM_freeN(link); + } + else { + /* avoid prepending 'data' to the path */ + RNA_id_pointer_create(id_data, &link->ptr); + } + id_data->flag &= ~LIB_DOIT; + } } + *r_lb = lb; + *r_path = path; } else if (GS(id->name) == ID_SCE) { /* Sequencer's ID is scene :/ */