From 67e2806dcbd3adfc1b691554ff22281a49db680a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 16 Mar 2018 16:44:23 +0100 Subject: Cleanup: naming and const parameter. --- source/blender/blenkernel/intern/icons.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 a98a1b13402..447a68e345a 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -431,13 +431,13 @@ void BKE_previewimg_ensure(PreviewImage *prv, const int size) } } -void BKE_icon_changed(int id) +void BKE_icon_changed(const int icon_id) { Icon *icon = NULL; - if (!id || G.background) return; + if (!icon_id || G.background) return; - icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(id)); + icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); if (icon) { PreviewImage *prv = BKE_previewimg_id_ensure((ID *)icon->obj); @@ -547,7 +547,7 @@ int BKE_icon_preview_ensure(ID *id, PreviewImage *preview) return preview->icon_id; } -Icon *BKE_icon_get(int icon_id) +Icon *BKE_icon_get(const int icon_id) { Icon *icon = NULL; @@ -561,7 +561,7 @@ Icon *BKE_icon_get(int icon_id) return icon; } -void BKE_icon_set(int icon_id, struct Icon *icon) +void BKE_icon_set(const int icon_id, struct Icon *icon) { void **val_p; @@ -584,7 +584,7 @@ void BKE_icon_id_delete(struct ID *id) /** * Remove icon and free data. */ -void BKE_icon_delete(int icon_id) +void BKE_icon_delete(const int icon_id) { Icon *icon; -- cgit v1.2.3 From 1a71d5ae85c8080705fc88188b6ef78aad29efdd Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 16 Mar 2018 17:06:43 +0100 Subject: Fix T54310: Assert when enable Brush custom icon. We had a mix of two issues here actually: * First, Brush are currently using their own sauce for custom previews, this is not great, but moving them to use common ImagePreview system of IDs is a low-priority TODO. For now, they should totally ignore their own ImagePreview. * Second, BKE_icon_changed() would systematically create a PreviewImage for ID types supporting it, which does not really makes sense, this function is merely here to 'tag' previews as outdated. Actual creation of previews is deferred to later, when we actually need them. --- source/blender/blenkernel/intern/icons.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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 447a68e345a..d56d758d4f0 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -440,14 +440,16 @@ void BKE_icon_changed(const int icon_id) icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); if (icon) { - PreviewImage *prv = BKE_previewimg_id_ensure((ID *)icon->obj); + /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure() here , + * we only want to ensure *existing* preview images are properly tagged as changed/invalid, that's all. */ + PreviewImage **p_prv = BKE_previewimg_id_get_p((ID *)icon->obj); - /* all previews changed */ - if (prv) { + /* If we have previews, they all are now invalid changed. */ + if (p_prv && *p_prv) { int i; for (i = 0; i < NUM_ICON_SIZES; ++i) { - prv->flag[i] |= PRV_CHANGED; - prv->changed_timestamp[i]++; + (*p_prv)->flag[i] |= PRV_CHANGED; + (*p_prv)->changed_timestamp[i]++; } } } -- cgit v1.2.3 From 5389964eea27c4d0129171ee69129210ee522bc3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 16 Mar 2018 17:17:19 +0100 Subject: Add an assert to BKE_icon_changed() that we are actually dealing with ID icon. Otherwise, ID->obj is an opaque pointer, wrong usage here could lead to a vast amount of bad things. --- source/blender/blenkernel/intern/icons.c | 3 +++ 1 file changed, 3 insertions(+) (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 d56d758d4f0..7302d62d20f 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -440,6 +440,9 @@ void BKE_icon_changed(const int icon_id) icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); if (icon) { + /* We *only* expect ID-tied icons here, not non-ID icon/preview! */ + BLI_assert(icon->type != 0); + /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure() here , * we only want to ensure *existing* preview images are properly tagged as changed/invalid, that's all. */ PreviewImage **p_prv = BKE_previewimg_id_get_p((ID *)icon->obj); -- cgit v1.2.3