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, and that undoing such deletion was impossible. Those issues have been fixed since several years now.
- Do write datablocks with zero users on save (the only exceptions could be library and linked data-blocks, I think?).
- 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)
- Likewise, when deleting any ID, also delete its animdata's Action if not used anywhere else.
- This could also be options in the user preferences (similar to what we have currently to control what gets duplicated).
- Make Purge accessible from the File menu and Blender File view in the outliner.
- Add an option to the Preferences, to run recursive purge on file save (see also T87490: Recursive Purge Orphans datablocks on file save).
- Changes to Purge operator itself:
- Make purge recursive (i.e. also delete IDs that are currently used, but would have no users once currently unused ones get deleted).
- 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 view 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.
About Fake User
- Tweak the ID template: remove the 'fake user' button, and have an 'unlink' button (X icon), and a delete button (trashcan icon).
- Keep fake user for use in the Outliner mostly (orphaned view, allows to do batch deletion while keeping some IDs with the purge button).
- Enable fake user by default for some data-block types:
- Materials, Textures, Images, Node groups.
- Brushes (already done iirc), Palettes…
- Fully remove Fake User, and instead rely on the new marked as asset feature to protect IDs from purge deletion.
- This would imply a do_version to convert existing 'fake users' to 'marked as assets' IDs.
- Code wise, changes should be very minimal, unless we have to do a lot of UI work (would not expect it).