T61141 raises again the issue of not writing IDs with zero users on file save. This has also been a long known pain for artists, especially when starting to work with Blender.
Historical reason for this behavior was that it used to be pretty impossible to properly delete an ID while Blender was running. This is not true anymore, since a few years work has been done to make this possible.
Proposal
- Do write datablocks with zero users on save (the only exceptions could be library and linked data-blocks, I think?).
- Keep fake user for use in the Outliner mostly (orphaned view, allows to do batch deletion while keeping some IDs with the purge button).
- We could also tweak the ID template: remove the 'fake user' button, and have an 'unlink' button (X icon), and a delete button (trashcan icon)?
- Enable fake user by default for some data-block types:
- Materials, Textures, Images, Node groups.
- Brushes (already done iirc), Palettes…
- Others?
- When deleting some IDs, also delete its 'dependencies' if they are no more used at all.
- Main case: when deleting object, also delete its object data, shape keys, particle systems, ... (this solves most of 'free large amounts of memory' issue)
- Likwise, when deleting any ID, also delete its animdata's Action if not used anywhere else.
- Make Purge accessible from the File menu and Blender File view in the outliner.
- Changes to Purge operator itself:
- Before it runs, show a popup with info on data types that will be deleted (5 materials, 3 meshes, etc) and allow users to confirm or cancel.
- Ideally should also allow expanded to see exactly which datablocks?
- Add option to select which data types to purge.
- After running, show "X datablocks deleted" message in the status bar.
- Make it not save and reload?
- Support undoing ID purge/deletion.
Notes
- Wanted to propose this since October actually, but this was always delayed by other stuff... Now that final release has been pushed back a bit, think we could sneak this in, also makes more sense to make that kind of change now than in 2.81 imho?
- Code wise, changes should be very minimal, unless we have to do a lot of UI work (would not expect it).