In a nutshell, the handling of dependencies in the 'append' part of the
code was not fully correct, and could break badly in some complex cases
(like appending complex hierarchies of data partially re-using some
dependencies from other previously appended data).
This could lead to e.g. some linked data referencing some local IDs...
straight way to crash in undo case (among many other problems).
Previous code was fairly compact and tried to be smart and efficient,
making some not-always-correct assumptions, and being quite hard to
fully understand.
So the first step of this fix was some refactoring:
* Splitting the post-process part of the 'link' case into its own
function (it is fairly trivial, and while it does duplicate some
logic to some extent, it makes the overall link/append process
clearer).
* Heavily refactoring the part of the 'append' code that decides how
to handle each linked ID.
The append-related post-processing is now significantly more complex,
but hopefully better divided in reasonably logical steps. And it is now
expected to deal with complex re-usability cases properly.
Pull Request: https://projects.blender.org/blender/blender/pulls/121867