diff options
author | Andrea Weikert <elubie@gmx.net> | 2011-05-18 23:42:30 +0400 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2011-05-18 23:42:30 +0400 |
commit | c04f9b779c4384f3cc6961b2ed54456bdab14f43 (patch) | |
tree | ef03665fdb965eac3636f89e837344723ed7a2ec /source/blender/blenkernel | |
parent | 91bd739a093f8bb3613f52b6a0edeacfd8c09d66 (diff) |
fix [#27158] Appending crash with preview.
* fixed incorrect reading of PreviewImage struct from .blend
* fixed memory leak, PreviewImage data wasn't correctly free'd
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_icons.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/icons.c | 22 |
2 files changed, 21 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h index 5404402718d..3c12a5d615d 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.h @@ -52,6 +52,7 @@ struct Icon typedef struct Icon Icon; struct PreviewImage; +struct ID; void BKE_icons_init(int first_dyn_id); @@ -74,11 +75,14 @@ void BKE_icon_changed(int icon_id); /* free all icons */ void BKE_icons_free(void); +/* free the preview image for use in list */ +void BKE_previewimg_freefunc(void *link); + /* free the preview image */ void BKE_previewimg_free(struct PreviewImage **prv); /* free the preview image belonging to the id */ -void BKE_previewimg_free_id(ID *id); +void BKE_previewimg_free_id(struct ID *id); /* create a new preview image */ struct PreviewImage* BKE_previewimg_create(void) ; @@ -87,6 +91,6 @@ struct PreviewImage* BKE_previewimg_create(void) ; struct PreviewImage* BKE_previewimg_copy(struct PreviewImage *prv); /* retrieve existing or create new preview image */ -PreviewImage* BKE_previewimg_get(ID *id); +struct PreviewImage* BKE_previewimg_get(struct ID *id); #endif /* BKE_ICONS_H */ diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 18eda831c47..9effd25c142 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -132,18 +132,26 @@ struct PreviewImage* BKE_previewimg_create(void) return prv_img; } -void BKE_previewimg_free(PreviewImage **prv) +void BKE_previewimg_freefunc(void *link) { - if(prv && (*prv)) { + PreviewImage *prv = (PreviewImage *)link; + if (prv) { int i; - + for (i=0; i<NUM_ICON_SIZES;++i) { - if ((*prv)->rect[i]) { - MEM_freeN((*prv)->rect[i]); - (*prv)->rect[i] = NULL; + if (prv->rect[i]) { + MEM_freeN(prv->rect[i]); + prv->rect[i] = NULL; } } - MEM_freeN((*prv)); + MEM_freeN(prv); + } +} + +void BKE_previewimg_free(PreviewImage **prv) +{ + if(prv && (*prv)) { + BKE_previewimg_freefunc(*prv); *prv = NULL; } } |