Readfile: Refactor several parts of the process #108016

Merged
Bastien Montagne merged 14 commits from mont29/blender:PR-setupappdata-refactor into main 2023-06-05 13:54:54 +02:00

14 Commits

Author SHA1 Message Date
Bastien Montagne 71d6431c2b Merge branch 'main' into PR-setupappdata-refactor 2023-06-05 13:54:06 +02:00
Bastien Montagne d48ee5085b Merge branch 'main' into PR-setupappdata-refactor
buildbot/vexp-code-patch-coordinator Build done. Details
2023-06-05 12:38:17 +02:00
Bastien Montagne 92e3ffdafb Merge branch 'main' into PR-setupappdata-refactor 2023-06-02 10:37:40 +02:00
Bastien Montagne 3e40243bee Remove ugly `old_wm` pointer in DNA WM struct, and use instead a temporary struct in WM readfile code.
buildbot/vexp-code-patch-coordinator Build done. Details
Much cleaner solution, athough a bit more verbose as this still needs to
be shared between WM and setup_app_data code...
2023-06-01 16:34:47 +02:00
Bastien Montagne 7cae80afdb Merge branch 'main' into PR-setupappdata-refactor 2023-06-01 11:45:52 +02:00
Bastien Montagne ce932dad2d Fix crash with specific test file, cleanup in comments. 2023-06-01 11:19:01 +02:00
Bastien Montagne afc4a2eebe Merge branch 'main' into PR-setupappdata-refactor 2023-05-31 17:08:17 +02:00
Bastien Montagne 502aa28d78 Merge branch 'main' into PR-setupappdata-refactor 2023-05-30 12:36:52 +02:00
Bastien Montagne 4063550c8a Cleanup: Typos in comments. 2023-05-26 19:28:36 +02:00
Bastien Montagne 5dbc3bcb1f Merge branch 'main' into PR-setupappdata-refactor 2023-05-26 19:26:12 +02:00
Bastien Montagne c1fe2ecc8d Merge branch 'main' into PR-setupappdata-refactor 2023-05-25 15:31:38 +02:00
Bastien Montagne e9da7ceff1 Address review comments. 2023-05-22 18:06:36 +02:00
Bastien Montagne e0add94e4a Merge branch 'main' into PR-setupappdata-refactor 2023-05-22 17:15:43 +02:00
Bastien Montagne 25f96f5a55 Readfile: Refactor several parts of the process.
This commit affects:
* Reading undo steps from memfile (aka 'Global Undo');
* Handling of UI IDs (WindowManager, Workspaces and Screens) when
  opening a .blend file.

While no major changes are expected from a user PoV, there may be some
unexpected changes in rare edge-cases. None has been identified so far.

Undo step loading should be marginally faster (`setup_app_data` itself
is 2-3 times faster, as it does not do remapping anymore, which makes the
whole 'read undo step' process about 20% faster - but the most
time-consuming step on undo is the depsgraph processing, which remains
unchanged here).

This commit also solves some bugs (crashes) in some relatively uncommon
cases, like e.g. if the WM had an IDProperty pointing at an object and
UI is not loaded when opening a new .blend file with the 'Load UI' option
enabled (as in previous code on file opening WM ID would never be
remapped).

From a more technical side, this commit aims mainly at cleaning things
up, in preparation for the introduction of new 'no undo, no readfile'
type of handling (as part of the Brush Assets project):
  - Prevent WM code from doing (too much) horrible ID 'management' on
    its WM when opening a new file. It used to remove current WM from
    the Main database, store it in a temporary own list, and then free
    it itself...
  - Trying to make the complex logic behind WM handling on file reading a
    bit more easy to follow, at least way more documented in code.
  - Keep the handling of 'IDs being re-used from old Main' in a single
    place, as much as possible:
    -- Readfile code itself in undo case (because it's more efficient,
       and undo case is in a way simpler than actual .blend file
       reading case). The whole `blo_lib_link_restore` block of code
       is also removed.
    -- (Mostly) setup_app_data code in actual file reading case.
  - Sanitize the usage of the 'libmap' in readfile code in undo case
    (waaaaay too many pointers were added there, which was hiding some
     other issues in the related code, and potentially causing (in
     rare cases) memory addresses collisions.
2023-05-19 16:45:11 +02:00