Blender won't update mesh's usercount when deleting object datablocks in Editmode
Open, ConfirmedPublic

Description

System Information
Xubuntu 14.04
Nvidia GTX 750 Ti

Blender Version
Stable Blender 2.79. Hash: 5bd8ac9abfa

Short description of error
Blender won't update mesh's usercount when deleting object datablocks in Editmode.
I don't know if this is a bug or just expected behaviour in this context, but let's see.

Exact steps for others to reproduce the error

  1. Open up Blender, select the default Cube and enter Editmode
  1. In a console, just add the current object to a variable.

    cube = bpy.context.object
  1. Create a new object datablock using the data from the previous object. Now the Cube's mesh datablock has 2 users.

    linked = bpy.data.objects.new("linked", cube.data)
  1. Delete the newly created object.

    bpy.data.objects.remove(linked, do_unlink=True)

And now, as you can see in the Object Data context, the Cube still has 2 users, even though the other Object doesn't exist in the Blend File.
I didn't found any way to update the user count. But I think this is a bug, because there's no problem when doing this in Object Mode.

I found this bug because I can't use the ray_cast function in Edit Mode (I need to keep in this mode), and I'm forced to create a temporal copy to use the function and then, discard the object. But when doing so, the mesh data usercount gets messed, though I can confirm it doesn't use any extra memory.

Details

Type
Bug
ronan ducluzeau (zeauro) triaged this task as Confirmed priority.Wed, Nov 22, 3:39 PM

I can reproduce the problem with 2.79 and master 69b5165.

It is really specific to edit mode.
It does not happen in Sculpt mode or Vertex paint mode, too.

I could see addition and deletion of object data in blend file view of outliner. But usercount is not updated.