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:
-rw-r--r--source/blender/blenkernel/BKE_library.h1
-rw-r--r--source/blender/blenkernel/intern/library.c12
-rw-r--r--source/blender/blenloader/intern/readfile.c8
3 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 23da122ed8b..b18d25094dc 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -58,6 +58,7 @@ int id_make_local(struct ID *id, int test);
int id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
int id_copy(struct ID *id, struct ID **newid, int test);
int id_unlink(struct ID *id, int test);
+void id_sort_by_name(struct ListBase *lb, struct ID *id);
int new_id(struct ListBase *lb, struct ID *id, const char *name);
void id_clear_lib_data(struct Main *bmain, struct ID *id);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 3c6c3f8c232..0506d606607 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1076,7 +1076,7 @@ void IMAnames_to_pupstring(const char **str, const char *title, const char *extr
BLI_dynstr_free(pupds);
}
-static void sort_alpha_id(ListBase *lb, ID *id)
+void id_sort_by_name(ListBase *lb, ID *id)
{
ID *idtest;
@@ -1086,7 +1086,7 @@ static void sort_alpha_id(ListBase *lb, ID *id)
idtest= lb->first;
while (idtest) {
- if (BLI_strcasecmp(idtest->name, id->name)>0 || idtest->lib) {
+ if (BLI_strcasecmp(idtest->name, id->name)>0 || (idtest->lib && !id->lib)) {
BLI_insertlinkbefore(lb, idtest, id);
break;
}
@@ -1270,10 +1270,10 @@ int new_id(ListBase *lb, ID *id, const char *tname)
* functions work, so sort every time */
#if 0
if ( result )
- sort_alpha_id(lb, id);
+ id_sort_by_name(lb, id);
#endif
- sort_alpha_id(lb, id);
+ id_sort_by_name(lb, id);
return result;
}
@@ -1415,7 +1415,7 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
/* why sort alphabetically here but not in
* id_clear_lib_data() ? - campbell */
- sort_alpha_id(lbarray[a], id);
+ id_sort_by_name(lbarray[a], id);
}
else {
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
@@ -1455,7 +1455,7 @@ void test_idbutton(char *name)
/* search for id */
idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);
- if (idtest) if ( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
+ if (idtest) if ( new_id(lb, idtest, name)==0 ) id_sort_by_name(lb, idtest);
}
void text_idbutton(struct ID *id, char *text)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 798c48dfaac..737a182bbe0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -14587,9 +14587,17 @@ static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, cons
found= 1;
id= is_yet_read(fd, mainl, bhead);
if (id==NULL) {
+ /* not read yet */
read_libblock(fd, mainl, bhead, LIB_TESTEXT, &id);
+
+ if (id) {
+ /* sort by name in list */
+ ListBase *lb= which_libbase(mainl, idcode);
+ id_sort_by_name(lb, id);
+ }
}
else {
+ /* already linked */
printf("append: already linked\n");
oldnewmap_insert(fd->libmap, bhead->old, id, 1);
if (id->flag & LIB_INDIRECT) {