From 7a2b18159170b91694fd7c64825a699314fae3ca Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 11 Jan 2022 11:27:35 +0100 Subject: Fix T94041: Loading a new file gives crash while rendering in viewport The issue was caused by Cycles display driver not being able to restore window's OpenGL context after disposing Cycles-side OpenGL context. This is due to the window OpenGL re-activation needing to access window manager which gets cleared out form global main during file reading. Defer clearing window manager from the global main to until after all screens are "exited". This allows Cycles to properly stop rendering, dispose its OpenGL context, and restore window's drawable context. It is unclear why it was required to clear window manager list early on. Guess is that it comes from an original code in a1c8543f2ac where there was an early return which then got replaced with an actual logic without changing the order of de-initialization and window manager list clear. Differential Revision: https://developer.blender.org/D13799 --- source/blender/windowmanager/intern/wm_files.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 99bab3ae23d..344f4959a93 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -193,7 +193,6 @@ bool wm_file_or_session_data_has_unsaved_changes(const Main *bmain, const wmWind static void wm_window_match_init(bContext *C, ListBase *wmlist) { *wmlist = G_MAIN->wm; - BLI_listbase_clear(&G_MAIN->wm); wmWindow *active_win = CTX_wm_window(C); @@ -220,6 +219,8 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) } } + BLI_listbase_clear(&G_MAIN->wm); + /* reset active window */ CTX_wm_window_set(C, active_win); -- cgit v1.2.3