[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28299] branches/render25/source/blender/ blenloader/intern/readfile.c: allow linked or appended files to themselves link data from the host . blend
Joseph Eagar
joeedh at gmail.com
Tue Apr 20 11:49:00 CEST 2010
Revision: 28299
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28299
Author: joeedh
Date: 2010-04-20 11:49:00 +0200 (Tue, 20 Apr 2010)
Log Message:
-----------
allow linked or appended files to themselves link data from the host .blend
Modified Paths:
--------------
branches/render25/source/blender/blenloader/intern/readfile.c
Modified: branches/render25/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/render25/source/blender/blenloader/intern/readfile.c 2010-04-20 09:28:15 UTC (rev 28298)
+++ branches/render25/source/blender/blenloader/intern/readfile.c 2010-04-20 09:49:00 UTC (rev 28299)
@@ -231,6 +231,7 @@
typedef struct OldNew {
void *old, *newp;
int nr;
+ int refself;
} OldNew;
typedef struct OldNewMap {
@@ -339,7 +340,7 @@
if(entry) {
ID *id= entry->newp;
- if (id && (!lib || id->lib)) {
+ if (id && (!lib || id->lib || entry->refself)) {
return entry->newp;
}
}
@@ -1135,6 +1136,20 @@
return id;
}
+static void id_allow_self_ref(FileData *fd, void *oldp)
+{
+ int i;
+
+ for (i=0; i<fd->libmap->nentries; i++) {
+ OldNew *entry= &fd->libmap->entries[i];
+
+ if (entry->old == oldp) {
+ entry->refself = 1;
+ break;
+ }
+ }
+}
+
static void change_idid_adr_fd(FileData *fd, void *old, void *new)
{
int i;
@@ -3423,7 +3438,7 @@
if (ob->id.properties) IDP_LibLinkProperty(ob->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
if (ob->adt) lib_link_animdata(fd, &ob->id, ob->adt);
-// XXX depreceated - old animation system <<<
+// XXX depreceated - old animat7ion system <<<
ob->ipo= newlibadr_us(fd, ob->id.lib, ob->ipo);
ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
// >>> XXX depreceated - old animation system
@@ -11111,7 +11126,7 @@
bhead= find_bhead(fd, old);
if(bhead) {
- /* from another library? */
+ /* from another library? */
if(bhead->code==ID_ID) {
BHead *bheadlib= find_previous_lib(fd, bhead);
@@ -11135,10 +11150,18 @@
* user.blend, lib.blend and lib_indirect.blend - if user.blend alredy references a "tree" from
* lib_indirect.blend but lib.blend does too, linking in a Scene or Group from lib.blend can result in an
* empty without the dupli group referenced. Once you save and reload the group would appier. - Campbell */
+
/* This crashes files, must look further into it */
- /*oldnewmap_insert(fd->libmap, bhead->old, id, 1);*/
-
- change_idid_adr_fd(fd, bhead->old, id);
+
+ //oldnewmap_insert(fd->libmap, bhead->old, id, 1);
+
+ /*if linked file references something in the host .blend, insert it into the map.
+ this exception should be safe to the "don't tun oldnewmap_insert here" problem. */
+ if (ptr == fd->mainlist.first) {
+ oldnewmap_insert(fd->libmap, bhead->old, id, 1);
+ id_allow_self_ref(fd, bhead->old);
+ } else change_idid_adr_fd(fd, bhead->old, id);
+
// commented because this can print way too much
// if(G.f & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
}
More information about the Bf-blender-cvs
mailing list