[Bf-blender-cvs] [32e6d5cd6f4] blender2.8: StudioLight: Fix crash when closing blender

Clément Foucault noreply at git.blender.org
Tue Sep 18 21:39:59 CEST 2018


Commit: 32e6d5cd6f407dac19cc73f9623f5166959b4273
Author: Clément Foucault
Date:   Tue Sep 18 15:35:51 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB32e6d5cd6f407dac19cc73f9623f5166959b4273

StudioLight: Fix crash when closing blender

The studiolight was being free after the window manager and was attempting
to stop the job again.

===================================================================

M	source/blender/editors/interface/interface_icons.c

===================================================================

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);
 						}
 					}



More information about the Bf-blender-cvs mailing list