diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-03-16 19:50:07 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-03-16 19:50:07 +0300 |
commit | dc08df659eaadd6c59c89f268aad9cd103e1e7e5 (patch) | |
tree | a9c9b9b05a0d38330f4d675175583d9ef96594b3 | |
parent | e15591a1d79b439fe539e627bb7331da093214cc (diff) | |
parent | 5389964eea27c4d0129171ee69129210ee522bc3 (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | source/blender/blenkernel/BKE_icons.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/icons.c | 27 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 1 |
3 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h index 39e6b145755..a9ca5cc8bbb 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.h @@ -58,19 +58,19 @@ int BKE_icon_id_ensure(struct ID *id); int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview); /* retrieve icon for id */ -struct Icon *BKE_icon_get(int icon_id); +struct Icon *BKE_icon_get(const int icon_id); /* set icon for id if not already defined */ /* used for inserting the internal icons */ -void BKE_icon_set(int icon_id, struct Icon *icon); +void BKE_icon_set(const int icon_id, struct Icon *icon); /* remove icon and free data if library object becomes invalid */ void BKE_icon_id_delete(struct ID *id); -void BKE_icon_delete(int icon_id); +void BKE_icon_delete(const int icon_id); /* report changes - icon needs to be recalculated */ -void BKE_icon_changed(int icon_id); +void BKE_icon_changed(const int icon_id); /* free all icons */ void BKE_icons_free(void); diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index a407fd0bae8..f3ff2c4425a 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -433,23 +433,28 @@ 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); + /* 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); - /* 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]++; } } } @@ -549,7 +554,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; @@ -563,7 +568,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; @@ -586,7 +591,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; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index aa37c9ffa88..ca8abdc8b48 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -441,7 +441,6 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi br->id.icon_id = 0; if (br->flag & BRUSH_CUSTOM_ICON) { - BKE_previewimg_id_ensure(&br->id); BKE_icon_changed(BKE_icon_id_ensure(&br->id)); } |