From 32e6d5cd6f407dac19cc73f9623f5166959b4273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 18 Sep 2018 15:35:51 +0200 Subject: StudioLight: Fix crash when closing blender The studiolight was being free after the window manager and was attempting to stop the job again. --- source/blender/editors/interface/interface_icons.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 8816d6acec8..50a5c711b2e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1051,6 +1051,10 @@ static void ui_studiolight_free_function(StudioLight *sl, void *data) { wmWindowManager *wm = data; + /* Happens if job was canceled or already finished. */ + if (wm == NULL) + return; + // get icons_id, get icons and kill wm jobs if (sl->icon_id_radiance) { ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_radiance); @@ -1066,6 +1070,14 @@ static void ui_studiolight_free_function(StudioLight *sl, void *data) } } +static void ui_studiolight_icon_job_end(void *customdata) +{ + Icon **tmp = (Icon **)customdata; + Icon *icon = *tmp; + StudioLight *sl = icon->obj; + BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, NULL); +} + void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big) { Icon *icon = BKE_icon_get(icon_id); @@ -1113,7 +1125,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi *tmp = icon; WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); - WM_jobs_callbacks(wm_job, ui_studiolight_icon_job_exec, NULL, NULL, NULL); + WM_jobs_callbacks(wm_job, ui_studiolight_icon_job_exec, NULL, NULL, ui_studiolight_icon_job_end); WM_jobs_start(CTX_wm_manager(C), wm_job); } } -- cgit v1.2.3