Page MenuHome

Duplicating objects with custom property of type ID creates bogus links
Closed, ResolvedPublic

Description

Blender Version
blender-2.81-95f020c853d6

When object A refers to object B via a custom property, duplicating A creates extra links on B.

Create a new scene with two objects, select the objects.
Run this in Python console:
bpy.types.Object.custom_reference = bpy.props.PointerProperty(type=bpy.types.Object, name="Test")
bpy.context.selected_objects[0].custom_reference = bpy.context.selected_objects[1]

Now you should see one of the objects having 2 (two) links in its datablock, as it should, and Custom Properties of the other should show the property.
Duplicate the referring object and check the other one. It will now have 4 (four) links, instead of 3. Delete the duplicate. The number of links will go down to 3 (three). Delete the last one with the custom property. Number of links will be 2.

Recreate the scene as above and duplicate the referring object. The target should again have the (incorrect) four links. Select all three objects and duplicate them. In that new trio, the copy of target will have a correct number of links (three). But the number of links on the original goes up to 6.

Event Timeline

Jacques Lucke (JacquesLucke) lowered the priority of this task from 90 to 50.

Can confirm the issue. The user count is incremented twice.

id_us_plus(ID * id) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:246)
IDP_CopyID(const IDProperty * prop, const int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/idprop.c:458)
IDP_CopyProperty_ex(const IDProperty * prop, const int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/idprop.c:762)
IDP_CopyGroup(const IDProperty * prop, const int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/idprop.c:485)
IDP_CopyProperty_ex(const IDProperty * prop, const int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/idprop.c:758)
BKE_libblock_copy_ex(Main * bmain, const ID * id, ID ** r_newid, const int orig_flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:1472)
BKE_id_copy_ex(Main * bmain, const ID * id, ID ** r_newid, const int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:663)
BKE_id_copy(Main * bmain, const ID * id, ID ** newid) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:797)
BKE_object_copy(Main * bmain, const Object * ob) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/object.c:1408)
BKE_object_duplicate(Main * bmain, const Object * ob, const int dupflag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/object.c:1431)
id_us_plus(ID * id) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:246)
id_copy_libmanagement_cb(void * user_data, ID * UNUSED_id_self, ID ** id_pointer, int cb_flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:606)
library_foreach_idproperty_ID_link(LibraryForeachIDData * data, IDProperty * prop, int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library_query.c:183)
library_foreach_idproperty_ID_link(LibraryForeachIDData * data, IDProperty * prop, int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library_query.c:171)
library_foreach_ID_link(Main * bmain, ID * id, LibraryIDLinkCallback callback, void * user_data, int flag, LibraryForeachIDData * inherit_data) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library_query.c:438)
BKE_library_foreach_ID_link(Main * bmain, ID * id, LibraryIDLinkCallback callback, void * user_data, int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library_query.c:1082)
BKE_id_copy_ex(Main * bmain, const ID * id, ID ** r_newid, const int flag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:776)
BKE_id_copy(Main * bmain, const ID * id, ID ** newid) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/library.c:797)
BKE_object_copy(Main * bmain, const Object * ob) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/object.c:1408)
BKE_object_duplicate(Main * bmain, const Object * ob, const int dupflag) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/object.c:1431)
  1. Open the file.
  2. Make sure you see the user count of the objects in the outliner.
  3. Duplicate the selected object.