Fix #134418: Double clicking a file crashes Blender if load UI is off

Screen initialization is more context dependent than it used to be
because of region polling, so the context needs to be set up correctly.
Here was a case where the initialized window/screen passed to polling
didn't match what's in context (UI context was unset in fact).

Some asserts could be added to ensure data passed to screen
initialization matches context, but can do that separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/135568
This commit is contained in:
Julian Eisel
2025-03-06 19:01:10 +01:00
committed by Julian Eisel
parent b4a1a140d7
commit b9907cb60b
@@ -847,7 +847,13 @@ void ED_screen_refresh(bContext *C, wmWindowManager *wm, wmWindow *win)
void ED_screens_init(bContext *C, Main *bmain, wmWindowManager *wm)
{
wmWindow *prev_ctx_win = CTX_wm_window(C);
BLI_SCOPED_DEFER([&]() { CTX_wm_window_set(C, prev_ctx_win); });
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
/* Region polls may need window/screen context. */
CTX_wm_window_set(C, win);
if (BKE_workspace_active_get(win->workspace_hook) == nullptr) {
BKE_workspace_active_set(win->workspace_hook,
static_cast<WorkSpace *>(bmain->workspaces.first));