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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-04-24 18:45:49 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-24 18:45:49 +0400
commitfd45310dfe30952081ef51f80e62543664ca84a5 (patch)
tree1c9babdc970a69ce1ebc569904ddd7f6c893295f /source
parent8fdebf24f4fe405c77f13a72c45cf0f8e6bc1f3f (diff)
fix crash [#27158] Appending crash with preview.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/BLO_readfile.h8
-rw-r--r--source/blender/blenloader/intern/readblenentry.c7
-rw-r--r--source/blender/editors/space_file/filelist.c16
3 files changed, 20 insertions, 11 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 891dc47b4ae..22083eda1c8 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -148,7 +148,7 @@ BLO_blendhandle_from_memory(
*
* @param bh The blendhandle to access.
* @param ofblocktype The type of names to get.
- * @param totnames The length of the returned list.
+ * @param tot_names The length of the returned list.
* @return A BLI_linklist of strings. The string links
* should be freed with malloc.
*/
@@ -156,7 +156,7 @@ BLO_blendhandle_from_memory(
BLO_blendhandle_get_datablock_names(
BlendHandle *bh,
int ofblocktype,
- int *totnames);
+ int *tot_names);
/**
* Gets the previews of all the datablocks in a file
@@ -165,13 +165,15 @@ BLO_blendhandle_get_datablock_names(
*
* @param bh The blendhandle to access.
* @param ofblocktype The type of names to get.
+ * @param tot_prev The length of the returned list.
* @return A BLI_linklist of PreviewImage. The PreviewImage links
* should be freed with malloc.
*/
struct LinkNode*
BLO_blendhandle_get_previews(
BlendHandle *bh,
- int ofblocktype);
+ int ofblocktype,
+ int *tot_prev);
/**
* Gets the names of all the datablock groups in a
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index ae4ba6629a6..abc469a5355 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -144,7 +144,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
return names;
}
-LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype)
+LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev)
{
FileData *fd= (FileData*) bh;
LinkNode *previews= NULL;
@@ -153,6 +153,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype)
int npreviews = 0;
PreviewImage* prv = NULL;
PreviewImage* new_prv = NULL;
+ int tot= 0;
for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
if (bhead->code==ofblocktype) {
@@ -166,6 +167,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype)
case ID_LA: /* fall through */
new_prv = MEM_callocN(sizeof(PreviewImage), "newpreview");
BLI_linklist_prepend(&previews, new_prv);
+ tot++;
looking = 1;
break;
default:
@@ -213,7 +215,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype)
}
}
-
+
+ *tot_prev= tot;
return previews;
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index f0ffe34476f..f815c7b4ac5 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1007,7 +1007,7 @@ void filelist_from_library(struct FileList* filelist)
{
LinkNode *l, *names, *previews;
struct ImBuf* ima;
- int ok, i, nnames, idcode;
+ int ok, i, nprevs, nnames, idcode;
char filename[FILE_MAXDIR+FILE_MAXFILE];
char dir[FILE_MAX], group[GROUP_MAX];
@@ -1031,17 +1031,18 @@ void filelist_from_library(struct FileList* filelist)
idcode= groupname_to_code(group);
- // memory for strings is passed into filelist[i].relname
- // and free'd in freefilelist
- previews = NULL;
+ /* memory for strings is passed into filelist[i].relname
+ * and free'd in freefilelist */
if (idcode) {
- previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode);
+ previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs);
names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames);
/* ugh, no rewind, need to reopen */
BLO_blendhandle_close(filelist->libfiledata);
filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL);
} else {
+ previews= NULL;
+ nprevs= 0;
names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata);
nnames= BLI_linklist_length(names);
}
@@ -1064,7 +1065,10 @@ void filelist_from_library(struct FileList* filelist)
}
}
- if(previews) {
+ if(previews && (nnames != nprevs)) {
+ printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs);
+ }
+ else if(previews) {
for (i=0, l= previews; i<nnames; i++, l= l->next) {
PreviewImage *img= l->link;