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>2007-04-07 21:35:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-04-07 21:35:47 +0400
commit76420c2fecdd57acf4fe0440fb681cf8f46707e4 (patch)
treea2ce3b28bf0d93aa4b2e241cc36a949f364d2a82 /source/blender
parent4fae78f8d9e1acd55a5d068ea4f161687c8efc0c (diff)
appending libdata no longer breaks all external references.
Existing data is flagged with LIB_APPEND_TAG and all_local only has an option to only operate on un-flagged data. If you append an object thats linked to a material alredy linked in your scene, the material will not be made local. So at worst youll need to make local some of the datablocks. This is fairly simple and though my tests show it to work, do some tests on your own libraries before assuming its problem free. scripttemplate_mesh_edit wasnt updated with PyAPI changes and moved some functions into generic places.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_library.h2
-rw-r--r--source/blender/blenkernel/intern/library.c11
-rw-r--r--source/blender/blenloader/intern/readfile.c1
-rw-r--r--source/blender/makesdna/DNA_ID.h2
-rw-r--r--source/blender/python/api2_2x/Library.c4
-rw-r--r--source/blender/src/editobject.c2
-rw-r--r--source/blender/src/filesel.c23
7 files changed, 33 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index f73c1b23a8a..064acf12eb5 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -62,7 +62,7 @@ void free_main(struct Main *mainvar);
void splitIDname(char *name, char *left, int *nr);
void rename_id(struct ID *id, char *name);
void test_idbutton(char *name);
-void all_local(struct Library *lib);
+void all_local(struct Library *lib, int untagged_only);
struct ID *find_id(char *type, char *name);
void clear_id_newpoins(void);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 803059ee0b4..a5a0c2bead2 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -983,7 +983,7 @@ static void lib_indirect_test_id(ID *id)
/* if lib!=NULL, only all from lib local */
-void all_local(Library *lib)
+void all_local(Library *lib, int untagged_only)
{
ListBase *lbarray[MAX_LIBARRAY], tempbase={0, 0};
ID *id, *idn;
@@ -997,7 +997,14 @@ void all_local(Library *lib)
id->newid= NULL;
idn= id->next; /* id is possibly being inserted again */
- if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW)) {
+ /* The check on the second line (LIB_APPEND_TAG) is done so its
+ * possible to tag data you dont want to be made local, used for
+ * appending data, so any libdata alredy linked wont become local
+ * (very nasty to discover all your links are lost after appending)
+ * */
+ if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
+ (untagged_only==0 || !(id->flag & LIB_APPEND_TAG)))
+ {
if(lib==NULL || id->lib==lib) {
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6ef6f18caee..41199d243f9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7480,7 +7480,6 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode)
}
}
}
- DAG_scene_sort(G.scene);
}
/* ************* READ LIBRARY ************** */
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 080d2861a19..ce03bdc5e84 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -215,6 +215,8 @@ typedef struct Library {
#define LIB_FAKEUSER 512
/* free test flag */
#define LIB_DOIT 1024
+/* */
+#define LIB_APPEND_TAG 2048
#ifdef __cplusplus
}
diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c
index daccf31489e..dd7cf18cb3d 100644
--- a/source/blender/python/api2_2x/Library.c
+++ b/source/blender/python/api2_2x/Library.c
@@ -416,7 +416,7 @@ static PyObject *M_Library_Update( PyObject * self )
break;
lib = lib->id.next;
}
- all_local( lib );
+ all_local( lib, 0 );
}
Py_INCREF( Py_None );
@@ -620,7 +620,7 @@ PyObject *LibraryData_importLibData( BPy_LibraryData *self, char *name,
for( lib = G.main->library.first; lib; lib = lib->id.next )
if( strcmp( longFilename, lib->name ) == 0 ) {
if( mode != FILE_LINK ) {
- all_local( lib );
+ all_local( lib, 0 );
lib = NULL;
}
break;
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 6e1bbe61039..0a1f29c0d48 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -4449,7 +4449,7 @@ void make_local(int mode)
if(G.scene->id.lib) return;
if(mode==3) {
- all_local(NULL); /* NULL is all libs */
+ all_local(NULL, 0); /* NULL is all libs */
allqueue(REDRAWALL, 0);
return;
}
diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c
index d2ac3115c0f..d8f1b732e19 100644
--- a/source/blender/src/filesel.c
+++ b/source/blender/src/filesel.c
@@ -2395,8 +2395,20 @@ static void do_library_append(SpaceFile *sfile)
Object *ob;
int idcode = groupname_to_code(group);
+ if((sfile->flag & FILE_LINK)==0) {
+ /* tag everything, all untagged data can be made local */
+ ID *id;
+ ListBase *lbarray[MAX_LIBARRAY];
+ int a;
+
+ a= set_listbasepointers(G.main, lbarray);
+ while(a--) {
+ for(id= lbarray[a]->first; id; id= id->next) id->flag |= LIB_APPEND_TAG;
+ }
+ }
+
BLO_library_append(sfile, dir, idcode);
-
+
/* DISPLISTS? */
ob= G.main->object.first;
while(ob) {
@@ -2413,14 +2425,15 @@ static void do_library_append(SpaceFile *sfile)
lib= lib->id.next;
}
- if(lib) {
- if((sfile->flag & FILE_LINK)==0)
- all_local(lib);
+ /* make local */
+ if(lib && (sfile->flag & FILE_LINK)==0) {
+ all_local(lib, 1);
}
+ DAG_scene_sort(G.scene);
+
/* in sfile->dir is the whole lib name */
BLI_strncpy(G.lib, sfile->dir, sizeof(G.lib) );
-
}
}