Fix T91809: Crash on undo with empty field inferencing

Some runtime data that stores which sockets can be fields and which
can't is not stored in the file, but only calculated when necessary.
When opening a file, the node tree update function was called, which
recalculated this data, but that was explicily turned off for undo.

This exposes a fundamental issue with undo, the ID caching system for
undo, and how it relates to node trees in particular. Ideally this call
couldn't be necessary at all. In the future it could be removed by
adding a runtime struct to node trees, and calculating its contents
on-demand instead of preemtively.

Differential Revision: https://developer.blender.org/D12699
This commit is contained in:
Hans Goudey 2021-10-12 15:38:56 -05:00
parent 9d03990e32
commit f18ab3470f
Notes: blender-bot 2023-02-14 08:42:54 +01:00
Referenced by issue #91809, Geometry nodes (Fields) Assertion failed at input_has_attribute_toggle()
1 changed files with 5 additions and 3 deletions

View File

@ -4027,11 +4027,13 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
* does not always properly handle user counts, and/or that function does not take into
* account old, deprecated data. */
BKE_main_id_refcount_recompute(bfd->main, false);
/* After all data has been read and versioned, uses LIB_TAG_NEW. */
ntreeUpdateAllNew(bfd->main);
}
/* After all data has been read and versioned, uses LIB_TAG_NEW. Theoretically this should
* not be calculated in the undo case, but it is currently needed even on undo to recalculate
* a cache. */
ntreeUpdateAllNew(bfd->main);
placeholders_ensure_valid(bfd->main);
BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false);