Page MenuHome

Material prevents itself from deletion
Closed, ArchivedPublic

Description

System Information
Windows 7 64, GTX 980

Blender Version
Broken: 2.73 + 000dfc0

Short description of error
Materials that are used as a Material Node in its own node setup, hold themself in the file, even if they have no real object/mesh they are assigned to.

Exact steps for others to reproduce the error

  • Add any mesh
    • Give it a "material"
    • Go to Node Editor: Enable "Use Nodes"
      • Choose "Material" (itself) as input for the Material Node
  • Delete this Material from the mesh

Problem:
The Node setup prevents the material to get deleted, although it isnt used at all.

This makes it hard to reorganise scenes where you want to append and delete lots of stuff. The Material list gets longer and you finally dont know what is really used and what not.

Event Timeline

Karja Krähwald (karja) raised the priority of this task from to 90.
Karja Krähwald (karja) updated the task description. (Show Details)
Karja Krähwald (karja) edited a custom field.

Yes, that’s creating some kind of circular dependency, node tree using the material which uses the node tree…

Sergey, you may have some advice here?

Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.Apr 3 2015, 10:46 AM

Maybe skip adding users to node trees who's IDs are the tree owner? Something like http://www.pasteall.org/57712/diff

Not sure how reliable it is, and it needs to be thought carefully, so we don't delete some datablock by accident.

@Sergey Sharybin (sergey), it can work but in that case other areas need to respect user count too,

Would need a custom set function in def_sh_material (which would conditionally adjust the user count). - also, ntreeSwitchID_ex, BKE_node_tree_unlink_id ... so worth checking on solution, but would want to make sure its working for all areas that access node->id

@Campbell Barton (campbellbarton), BKE_node_tree_unlink_id does not do user counting, but ntreeSwitchID_ex will indeed give problems. Annoying thing is that it's not always known for sure where the node tree is coming from. Suggested approach will end up passing owner of node tree to those functions, which is rather annoying.

Unless there's some better ideas here would rather move this to TODO, maybe even something related to assets works which is being happened now.

Julian Eisel (Severin) changed the task status from Unknown Status to Unknown Status.Jun 28 2015, 10:38 PM
Julian Eisel (Severin) claimed this task.

Closing as todo for now.