Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2018-06-20 10:29:40 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2018-06-20 10:29:40 +0300
commite3052ecb0d246381558c75219962915140bbe4ca (patch)
treea05e59c7c0b94b18bb45fe884bee6af920e241c2 /source/blender/editors/interface
parent91c0f17a475793de7bc6016598ef13221392dbf5 (diff)
Studiolight: removed raise condition
Happened when deleting many studiolights at the same time when the previews were still beging calculated in the background. Added a free function callback that is filled when the preview is being generated. This free function will then kill the preview job This patch also removes icons that are not valid anymore so the user cannot accidentally render an icon where the studiolight is invalid. In the end we should use a add/remove function in the studiolight as currently icons are recalculated too much.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_icons.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 3272e9f14a2..539dd05b242 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -851,6 +851,32 @@ static void ui_studiolight_icon_job_exec(void *customdata, short *UNUSED(stop),
BKE_studiolight_preview(di->data.buffer.image->rect, sl, icon->id_type);
}
+static void ui_studiolight_kill_icon_preview_job(wmWindowManager *wm, int icon_id)
+{
+ Icon *icon = BKE_icon_get(icon_id);
+ WM_jobs_kill_type(wm, icon, WM_JOB_TYPE_STUDIOLIGHT);
+ icon->obj = NULL;
+}
+
+static void ui_studiolight_free_function(StudioLight * sl, void* data)
+{
+ wmWindowManager *wm = data;
+
+ // 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);
+ }
+ if (sl->icon_id_irradiance) {
+ ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_irradiance);
+ }
+ if (sl->icon_id_matcap) {
+ ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_matcap);
+ }
+ if (sl->icon_id_matcap_flipped) {
+ ui_studiolight_kill_icon_preview_job(wm, sl->icon_id_matcap_flipped);
+ }
+}
+
void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
{
Icon *icon = BKE_icon_get(icon_id);
@@ -881,6 +907,9 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
{
if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
if (di->data.buffer.image == NULL) {
+ wmWindowManager *wm = CTX_wm_manager(C);
+ StudioLight *sl = icon->obj;
+ BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm);
IconImage *img = MEM_mallocN(sizeof(IconImage), __func__);
img->w = STUDIOLIGHT_ICON_SIZE;
@@ -890,7 +919,7 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
memset(img->rect, 0, size);
di->data.buffer.image = img;
- wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
+ wmJob *wm_job = WM_jobs_get(wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
Icon** tmp = MEM_callocN(sizeof(Icon*), __func__);
*tmp = icon;
WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);