diff options
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 88 |
1 files changed, 56 insertions, 32 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 942d5516dc7..a9e9a07a2b1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1776,6 +1776,27 @@ static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData } } +#define IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd) \ + _IDP_DirectLinkGroup_OrFree(prop, switch_endian, fd, __func__) + +static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop, int switch_endian, FileData *fd, + const char *caller_func_id) +{ + if (*prop) { + if ((*prop)->type == IDP_GROUP) { + IDP_DirectLinkGroup(*prop, switch_endian, fd); + } + else { + /* corrupt file! */ + printf("%s: found non group data, freeing type %d!\n", + caller_func_id, (*prop)->type); + /* don't risk id, data's likely corrupt. */ + // IDP_FreeProperty(*prop); + *prop = NULL; + } + } +} + /* stub function */ static void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endian), FileData *UNUSED(fd)) { @@ -1788,9 +1809,8 @@ static void direct_link_id(FileData *fd, ID *id) /*link direct data of ID properties*/ if (id->properties) { id->properties = newdataadr(fd, id->properties); - if (id->properties) { /* this case means the data was written incorrectly, it should not happen */ - IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - } + /* this case means the data was written incorrectly, it should not happen */ + IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } } @@ -2041,7 +2061,7 @@ static void direct_link_fmodifiers(FileData *fd, ListBase *list) FMod_Python *data = (FMod_Python *)fcm->data; data->prop = newdataadr(fd, data->prop); - IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } break; } @@ -2596,8 +2616,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) static void direct_link_node_socket(FileData *fd, bNodeSocket *sock) { sock->prop = newdataadr(fd, sock->prop); - if (sock->prop) - IDP_DirectLinkProperty(sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); sock->link = newdataadr(fd, sock->link); sock->typeinfo = NULL; @@ -2635,8 +2654,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) link_list(fd, &node->outputs); node->prop = newdataadr(fd, node->prop); - if (node->prop) - IDP_DirectLinkProperty(node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&node->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); link_list(fd, &node->internal_links); for (link = node->internal_links.first; link; link = link->next) { @@ -2794,8 +2812,7 @@ static void direct_link_constraints(FileData *fd, ListBase *lb) link_list(fd, &data->targets); data->prop = newdataadr(fd, data->prop); - if (data->prop) - IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); break; } case CONSTRAINT_TYPE_SPLINEIK: @@ -2894,8 +2911,7 @@ static void direct_link_bones(FileData *fd, Bone *bone) bone->parent = newdataadr(fd, bone->parent); bone->prop = newdataadr(fd, bone->prop); - if (bone->prop) - IDP_DirectLinkProperty(bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); bone->flag &= ~BONE_DRAW_ACTIVE; @@ -4148,12 +4164,6 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) direct_link_customdata(fd, &mesh->fdata, mesh->totface); direct_link_customdata(fd, &mesh->ldata, mesh->totloop); direct_link_customdata(fd, &mesh->pdata, mesh->totpoly); - - if (mesh->mloopuv || mesh->mtpoly) { - /* for now we have to ensure texpoly and mloopuv layers are aligned - * in the future we may allow non-aligned layers */ - BKE_mesh_cd_validate(mesh); - } mesh->bb = NULL; mesh->edit_btmesh = NULL; @@ -4163,6 +4173,12 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) mesh->totselect = 0; } + if (mesh->mloopuv || mesh->mtpoly) { + /* for now we have to ensure texpoly and mloopuv layers are aligned + * in the future we may allow non-aligned layers */ + BKE_mesh_cd_validate(mesh); + } + /* Multires data */ mesh->mr= newdataadr(fd, mesh->mr); if (mesh->mr) { @@ -4544,8 +4560,7 @@ static void direct_link_pose(FileData *fd, bPose *pose) direct_link_constraints(fd, &pchan->constraints); pchan->prop = newdataadr(fd, pchan->prop); - if (pchan->prop) - IDP_DirectLinkProperty(pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); pchan->mpath = newdataadr(fd, pchan->mpath); if (pchan->mpath) @@ -5445,10 +5460,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) } if (sce->r.ffcodecdata.properties) { sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties); - if (sce->r.ffcodecdata.properties) { - IDP_DirectLinkProperty(sce->r.ffcodecdata.properties, - (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - } + IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } link_list(fd, &(sce->markers)); @@ -6142,8 +6154,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) ui_list->type = NULL; ui_list->dyn_data = NULL; ui_list->properties = newdataadr(fd, ui_list->properties); - if (ui_list->properties) - IDP_DirectLinkProperty(ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } if (spacetype == SPACE_EMPTY) { @@ -9709,11 +9720,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + if (!MAIN_VERSION_ATLEAST(main, 269, 1)) { + /* Removal of Cycles SSS Compatible falloff */ + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_SHADER) { + bNode *node; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == SH_NODE_SUBSURFACE_SCATTERING) { + if (node->custom1 == SHD_SUBSURFACE_COMPATIBLE) { + node->custom1 = SHD_SUBSURFACE_CUBIC; + } + } + } + } + } FOREACH_NODETREE_END + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */ - /* don't forget to set version number in blender.c! */ + /* don't forget to set version number in BKE_blender.h! */ } #if 0 // XXX: disabled for now... we still don't have this in the right place in the loading code for it to work @@ -9769,8 +9796,7 @@ static void lib_link_all(FileData *fd, Main *main) static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi) { kmi->properties = newdataadr(fd, kmi->properties); - if (kmi->properties) - IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + IDP_DirectLinkGroup_OrFree(&kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); kmi->ptr = NULL; kmi->flag &= ~KMI_UPDATE; } @@ -9827,9 +9853,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) for (addon = user->addons.first; addon; addon = addon->next) { addon->prop = newdataadr(fd, addon->prop); - if (addon->prop) { - IDP_DirectLinkProperty(addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - } + IDP_DirectLinkGroup_OrFree(&addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } // XXX |