Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-09-30 15:49:42 +0300
committerBastien Montagne <bastien@blender.org>2020-10-02 12:47:34 +0300
commit6219d0d145d3f2e6bd30be1c91e952e18db44e74 (patch)
treebef402396e0076094364277403922709f8fc60ce /source/blender/windowmanager/intern/wm_window.c
parentd74d35e39eaf97a63178c84a6c4e9ab4e0bc384c (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/windowmanager/intern/wm_window.c')
-rw-r--r--source/blender/windowmanager/intern/wm_window.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 610a06690cc..e8575374022 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -297,7 +297,7 @@ wmWindow *wm_window_new(const Main *bmain, wmWindowManager *wm, wmWindow *parent
/* Dialogs may have a child window as parent. Otherwise, a child must not be a parent too. */
win->parent = (!dialog && parent && parent->parent) ? parent->parent : parent;
win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo 3D Format (window)");
- win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
+ win->workspace_hook = BKE_workspace_instance_hook_create(bmain, win->winid);
return win;
}
@@ -327,7 +327,7 @@ wmWindow *wm_window_copy(Main *bmain,
layout_new = duplicate_layout ?
ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) :
layout_old;
- BKE_workspace_active_layout_set(win_dst->workspace_hook, workspace, layout_new);
+ BKE_workspace_active_layout_set(win_dst->workspace_hook, win_dst->winid, workspace, layout_new);
*win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -2420,7 +2420,7 @@ WorkSpaceLayout *WM_window_get_active_layout(const wmWindow *win)
}
void WM_window_set_active_layout(wmWindow *win, WorkSpace *workspace, WorkSpaceLayout *layout)
{
- BKE_workspace_active_layout_set(win->workspace_hook, workspace, layout);
+ BKE_workspace_active_layout_set(win->workspace_hook, win->winid, workspace, layout);
}
/**
@@ -2434,7 +2434,7 @@ bScreen *WM_window_get_active_screen(const wmWindow *win)
}
void WM_window_set_active_screen(wmWindow *win, WorkSpace *workspace, bScreen *screen)
{
- BKE_workspace_active_screen_set(win->workspace_hook, workspace, screen);
+ BKE_workspace_active_screen_set(win->workspace_hook, win->winid, workspace, screen);
}
bool WM_window_is_temp_screen(const wmWindow *win)