Fix T92704: Redrawing while saving crashes outside the main thread

If the blend file is saved from a script in another thread,
like the render thread for example, Blender will crash on the call that
redraws the UI.

Ref D13140
This commit is contained in:
Jeducious 2021-11-09 15:13:40 +11:00 committed by Campbell Barton
parent ab7214ca2e
commit afc60f9957
Notes: blender-bot 2023-02-14 00:20:15 +01:00
Referenced by issue #92704, Blender crashes when attempting to save the blend file from a script prior to rendering
1 changed files with 3 additions and 2 deletions

View File

@ -1793,8 +1793,9 @@ static bool wm_file_write(bContext *C,
/* Enforce full override check/generation on file save. */
BKE_lib_override_library_main_operations_create(bmain, true);
if (!G.background) {
/* Redraw to remove menus that might be open. */
if (!G.background && BLI_thread_is_main()) {
/* Redraw to remove menus that might be open.
* But only in the main thread otherwise this can crash, see T92704. */
WM_redraw_windows(C);
}