Sound: Fix access wrong dependency graph

Due to some fields in the context being NULL access was happening
to the default view layer, not the active one.

Simply re-arranged context initialization, so it happens before
accessing dependnecy graph.

Fixes T64183: Crash in BKE_sound_scene_playing due to Scene NULL
Fixes T64192: Crash opening a file with a non-default View Layer active
This commit is contained in:
Sergey Sharybin 2019-05-06 11:29:25 +02:00
parent 22e9365e8b
commit 2e582f8ab5

@ -3091,8 +3091,12 @@ void wm_event_do_handlers(bContext *C)
wm_event_free_all(win);
}
else {
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = WM_window_get_active_scene(win);
CTX_wm_window_set(C, win);
CTX_data_scene_set(C, scene);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
if (scene) {
@ -3100,8 +3104,6 @@ void wm_event_do_handlers(bContext *C)
if (is_playing_sound != -1) {
bool is_playing_screen;
CTX_wm_window_set(C, win);
CTX_data_scene_set(C, scene);
is_playing_screen = (ED_screen_animation_playing(wm) != NULL);
@ -3121,12 +3123,12 @@ void wm_event_do_handlers(bContext *C)
}
}
}
CTX_data_scene_set(C, NULL);
CTX_wm_screen_set(C, NULL);
CTX_wm_window_set(C, NULL);
}
}
CTX_data_scene_set(C, NULL);
CTX_wm_screen_set(C, NULL);
CTX_wm_window_set(C, NULL);
}
while ((event = win->queue.first)) {