diff options
author | Bastien Montagne <bastien@blender.org> | 2020-09-30 15:49:42 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-10-02 12:47:34 +0300 |
commit | 6219d0d145d3f2e6bd30be1c91e952e18db44e74 (patch) | |
tree | bef402396e0076094364277403922709f8fc60ce /source/blender/blenloader/intern/versioning_280.c | |
parent | d74d35e39eaf97a63178c84a6c4e9ab4e0bc384c (diff) |
Fix (unreported) design flow in how workspace's relation data are read from .blend file.
Relying on pointer addresses across different data-blocks is extremely
not recommended (and should be strictly forbidden ideally), in
particular in direct_link step of blend file reading.
- It assumes a specific order in reading of data, which is not ensured
in future, and is in any case a very bad, non explicit, hidden
dependency on behaviors of other parts of the codebase.
- It is intrinsically unsafe (as in, it makes writing bad code and making
mistakes easy, see e.g. fix in rB84b3f6e049b35f9).
- It makes advanced handling of data-blocks harder (thinking about
partial undo code e.g., even though in this specific case it was not
an issue as we do not re-read neither windowmanagers nor worspaces
during undo).
New code uses windows' `winid` instead as 'anchor' to find again proper
workspace hook in windows at read time.
As a bonus, it will also cleanup the list of relations from any invalid
ones (afaict it was never done previously).
Differential Revision: https://developer.blender.org/D9073
Diffstat (limited to 'source/blender/blenloader/intern/versioning_280.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 14a4643f760..b7c48234590 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -241,7 +241,7 @@ static void do_version_workspaces_after_lib_link(Main *bmain) if (screen->temp) { /* We do not generate a new workspace for those screens... * still need to set some data in win. */ - win->workspace_hook = BKE_workspace_instance_hook_create(bmain); + win->workspace_hook = BKE_workspace_instance_hook_create(bmain, win->winid); win->scene = screen->scene; /* Deprecated from now on! */ win->screen = NULL; @@ -254,10 +254,10 @@ static void do_version_workspaces_after_lib_link(Main *bmain) WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win->screen); BLI_assert(layout != NULL); - win->workspace_hook = BKE_workspace_instance_hook_create(bmain); + win->workspace_hook = BKE_workspace_instance_hook_create(bmain, win->winid); BKE_workspace_active_set(win->workspace_hook, workspace); - BKE_workspace_active_layout_set(win->workspace_hook, workspace, layout); + BKE_workspace_active_layout_set(win->workspace_hook, win->winid, workspace, layout); /* Move scene and view layer to window. */ Scene *scene = screen->scene; |