user_remap on itself changes users to 0 #51150

Closed
opened 2017-04-07 18:52:33 +02:00 by Lemon Acidjuice · 8 comments

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.

A minor point. But it has an impact on some cleanup scripts, for instance [this one ](http://blender.stackexchange.com/questions/77187/recalculate-image-users-after-user-remap). 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.

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @LemonAcidjuice

Added subscriber: @LemonAcidjuice

Added subscribers: @mont29, @Sergey

Added subscribers: @mont29, @Sergey
Bastien Montagne was assigned by Sergey Sharybin 2017-04-12 16:28:26 +02:00

@mont29, guess this is something for you to check out.

@mont29, guess this is something for you to check out.

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)…

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)…

Test2.blend (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.

@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).

[Test2.blend](https://archive.blender.org/developer/F545977/Test2.blend) (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. @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).

This issue was referenced by 4d0d1b5936

This issue was referenced by 4d0d1b5936c59b6e7ce5b3ae8b1af617cbdada61

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#51150
No description provided.