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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-12 17:38:00 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-12 17:38:00 +0300
commita41694938231a108ed414561311663c3c4ae7c4c (patch)
treefa491b06eebd640b88bde199ac82e150d5c89a3b
parentc678bd2d7de115945e5df83b11742a62582c4d40 (diff)
- BKE_idcode_iter_step() - function to step over all ID codes.
- BLO_blendhandle_get_datablock_names() now takes an arg for the total items in the list, saves the caller counting.
-rw-r--r--source/blender/blenkernel/BKE_idcode.h8
-rw-r--r--source/blender/blenkernel/intern/idcode.c5
-rw-r--r--source/blender/blenloader/BLO_readfile.h4
-rw-r--r--source/blender/blenloader/intern/readblenentry.c9
-rw-r--r--source/blender/editors/space_file/filelist.c5
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp5
6 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_idcode.h b/source/blender/blenkernel/BKE_idcode.h
index 1b2b3d2ee95..e46ad450c31 100644
--- a/source/blender/blenkernel/BKE_idcode.h
+++ b/source/blender/blenkernel/BKE_idcode.h
@@ -76,4 +76,12 @@ int BKE_idcode_is_linkable(int code);
*/
int BKE_idcode_is_valid(int code);
+/**
+ * Return an ID code and steps the index forward 1.
+ *
+ * @param index, start as 0.
+ * @return the code, 0 when all codes have been returned.
+ */
+int BKE_idcode_iter_step(int *index);
+
#endif
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 0779e1cc017..8c8a693e6e7 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -133,3 +133,8 @@ const char *BKE_idcode_to_name_plural(int code)
return idt?idt->plural:NULL;
}
+
+int BKE_idcode_iter_step(int *index)
+{
+ return (*index < nidtypes) ? idtypes[(*index)++].code : 0;
+}
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 681e014c2ec..f890f169eec 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -146,13 +146,15 @@ 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.
* @return A BLI_linklist of strings. The string links
* should be freed with malloc.
*/
struct LinkNode*
BLO_blendhandle_get_datablock_names(
BlendHandle *bh,
- int ofblocktype);
+ int ofblocktype,
+ int *totnames);
/**
* Gets the previews of all the datablocks in a file
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index eda0ac1c375..4a8ef3a9317 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -123,21 +123,24 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
fprintf(fp, "]\n");
}
-LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype)
+LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, int *tot_names)
{
FileData *fd= (FileData*) bh;
LinkNode *names= NULL;
BHead *bhead;
+ int tot= 0;
for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
if (bhead->code==ofblocktype) {
char *idname= bhead_id_name(fd, bhead);
-
+
BLI_linklist_prepend(&names, strdup(idname+2));
+ tot++;
} else if (bhead->code==ENDB)
break;
}
-
+
+ *tot_names= tot;
return names;
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index bd188d07a86..0eee8eb0712 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -997,16 +997,15 @@ void filelist_from_library(struct FileList* filelist)
previews = NULL;
if (idcode) {
previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode);
- names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode);
+ 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);
} else {
names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata);
+ nnames= BLI_linklist_length(names);
}
-
- nnames= BLI_linklist_length(names);
filelist->numfiles= nnames + 1;
filelist->filelist= malloc(filelist->numfiles * sizeof(*filelist->filelist));
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index a98fe87a0ef..49f6b94023c 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -984,8 +984,9 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
/* here appending/linking starts */
main_tmp = BLO_library_append_begin(C, &bpy_openlib, (char *)path);
-
- names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode);
+
+ int totnames_dummy;
+ names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode, &totnames_dummy);
int i=0;
LinkNode *n= names;