From 8f8ed8f5670b96c129b1d1026a70ebf8067036b3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 23 Aug 2020 13:44:18 +1000 Subject: Fix T80028: Crash opening a file from a timer --- source/blender/windowmanager/intern/wm_event_system.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index c72c9ce906b..6f7c074c704 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -390,6 +390,9 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) static void wm_event_execute_timers(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); + if (UNLIKELY(wm == NULL)) { + return; + } /* Set the first window as context, so that there is some minimal context. This avoids crashes * when calling code that assumes that there is always a window in the context (which many @@ -402,16 +405,17 @@ static void wm_event_execute_timers(bContext *C) /* called in mainloop */ void wm_event_do_notifiers(bContext *C) { - wmWindowManager *wm = CTX_wm_manager(C); wmNotifier *note, *next; wmWindow *win; + /* Run the timer before assigning 'wm' in the unlikely case a timer loads a file, see T80028. */ + wm_event_execute_timers(C); + + wmWindowManager *wm = CTX_wm_manager(C); if (wm == NULL) { return; } - wm_event_execute_timers(C); - /* disable? - keep for now since its used for window level notifiers. */ #if 1 /* cache & catch WM level notifiers, such as frame change, scene/screen set */ -- cgit v1.2.3