Page MenuHome

user_remap on itself changes users to 0
Closed, ResolvedPublic

Description

A minor point. But it has an impact on some cleanup scripts, for instance this one.

Using 'user_remap' on the object itself sometimes changes 'users' to zero.

Here is an example:

> i=bpy.data.images['
                       CrackedSand2.tga']
                       Desertrocku.tga']
                       Desertrocku2.tga']
                       G3_Desert_Rock.tga']
                       G3_PlainSand_02.tga']
                       G3_PlainSand_Blut.tga']
                       G3_PlainSand_Blut2.tga']
                       ROCK6.tga']
                       ROCK6u.tga']
                       SandDunesBig.tga']
                       Untitled']
> i=bpy.data.images['Untitled']
> i.users
1

> i.user_remap(i)
> i.users
1

> i=bpy.data.images['SandDunesBig.tga']
> i.users
1

> i.user_remap(i)
> i.users
0

The behavior seems to be random.

Event Timeline

Sergey Sharybin (sergey) lowered the priority of this task from 90 to Normal.

@Bastien Montagne (mont29), guess this is something for you to check out.

Bastien Montagne (mont29) triaged this task as 30 priority.Apr 12 2017, 7:59 PM

I’ll need a file to reproduce this… Also remapping to itself is somewhat stupid, should probably just be an 'early return' case (or even error on it)…

(same file as the one you can reach from the indicated link in the first post). You can try it with "i=bpy.data.images['ROCK6.tga']" in the Python console.

@Bastien Montagne (mont29) I'm aware this is stupid, but two aspects: non experimented users/coders are lost with this kind of things and this could hide a deeper pointers handling problem (smart pointers, I presume it is, problem may involve memory leaks). FYI, I failed to reproduce it on any of my blend files, and as explained of the first post, the behavior is erratic even in the linked file (so I do not know what the OP of the BSE question have done before he shared his file).