From e3052ecb0d246381558c75219962915140bbe4ca Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 20 Jun 2018 09:29:40 +0200 Subject: 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. --- source/blender/blenkernel/intern/icons.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/icons.c') diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index e6afe08e19a..37f53e81236 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -119,7 +119,7 @@ static void icon_free(void *val) } } -static void icon_free_data(Icon *icon) +static void icon_free_data(int icon_id, Icon *icon) { if (icon->obj_type == ICON_DATA_ID) { ((ID *)(icon->obj))->icon_id = 0; @@ -130,6 +130,12 @@ static void icon_free_data(Icon *icon) else if (icon->obj_type == ICON_DATA_GEOM) { ((struct Icon_Geom *)(icon->obj))->icon_id = 0; } + else if (icon->obj_type == ICON_DATA_STUDIOLIGHT) { + StudioLight *sl = icon->obj; + if (sl != NULL) { + BKE_studiolight_unset_icon_id(sl, icon_id); + } + } else { BLI_assert(0); } @@ -699,7 +705,7 @@ bool BKE_icon_delete(const int icon_id) Icon *icon = BLI_ghash_popkey(gIcons, SET_INT_IN_POINTER(icon_id), NULL); if (icon) { - icon_free_data(icon); + icon_free_data(icon_id, icon); icon_free(icon); return true; } @@ -722,7 +728,7 @@ bool BKE_icon_delete_unmanaged(const int icon_id) return false; } else { - icon_free_data(icon); + icon_free_data(icon_id, icon); icon_free(icon); return true; } -- cgit v1.2.3