diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-05-04 18:00:40 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-05-04 18:14:25 +0300 |
commit | bf7e8b42fa269c310e456fa55263ff2d9849804e (patch) | |
tree | 571b8177bc7d854c865126e8c11b680577b0d98c /source/blender/blenloader/intern | |
parent | 20e960215a80a41fd7e9782d009531d8d9f827cd (diff) | |
parent | 1227e5c3d1ee20e9af57984a261b1d51d48c0263 (diff) |
Merge branch 'master' into strand_editmode
Conflicts:
source/blender/bmesh/bmesh_class.h
source/blender/bmesh/intern/bmesh_mesh_conv.h
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 23 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 32 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 77 |
3 files changed, 103 insertions, 29 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1b9cc0063a6..c9952926913 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2639,7 +2639,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) * New file versions already have input/output nodes with duplicate links, * in that case just remove the invalid links. */ - int create_io_nodes = (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE); + const bool create_io_nodes = (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE) != 0; float input_locx = 1000000.0f, input_locy = 0.0f; float output_locx = -1000000.0f, output_locy = 0.0f; @@ -3532,7 +3532,7 @@ static void direct_link_curve(FileData *fd, Curve *cu) nu->bp = newdataadr(fd, nu->bp); nu->knotsu = newdataadr(fd, nu->knotsu); nu->knotsv = newdataadr(fd, nu->knotsv); - if (cu->vfont == NULL) nu->charidx= nu->mat_nr; + if (cu->vfont == NULL) nu->charidx = 0; if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { switch_endian_knots(nu); @@ -5829,6 +5829,12 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) win->lastcursor = 0; win->modalcursor = 0; win->stereo3d_format = newdataadr(fd, win->stereo3d_format); + + /* multiview always fallback to anaglyph at file opening + * otherwise quadbuffer saved files can break Blender */ + if (win->stereo3d_format) { + win->stereo3d_format->display_mode = S3D_DISPLAY_ANAGLYPH; + } } BLI_listbase_clear(&wm->timers); @@ -5979,6 +5985,9 @@ static void lib_link_screen(FileData *fd, Main *main) else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid); + if (sbuts->pinid == NULL) { + sbuts->flag &= ~SB_PIN_CONTEXT; + } } else if (sl->spacetype == SPACE_FILE) { ; @@ -6308,6 +6317,9 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, USER_IGNORE); + if (sbuts->pinid == NULL) { + sbuts->flag &= ~SB_PIN_CONTEXT; + } /* TODO: restore path pointers: T40046 * (complicated because this contains data pointers too, not just ID)*/ @@ -7085,7 +7097,7 @@ static void direct_link_moviePlaneTracks(FileData *fd, ListBase *plane_tracks_ba int i; plane_track->point_tracks = newdataadr(fd, plane_track->point_tracks); - + test_pointer_array(fd, (void**)&plane_track->point_tracks); for (i = 0; i < plane_track->point_tracksnr; i++) { plane_track->point_tracks[i] = newdataadr(fd, plane_track->point_tracks[i]); } @@ -7809,12 +7821,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (G.debug & G_DEBUG) { char build_commit_datetime[32]; time_t temp_time = main->build_commit_timestamp; - struct tm *tm = gmtime(&temp_time); + struct tm *tm = (temp_time) ? gmtime(&temp_time) : NULL; if (LIKELY(tm)) { strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm); } else { - BLI_strncpy(build_commit_datetime, "date-unknown", sizeof(build_commit_datetime)); + BLI_strncpy(build_commit_datetime, "unknown", sizeof(build_commit_datetime)); } printf("read file %s\n Version %d sub %d date %s hash %s\n", @@ -9245,7 +9257,6 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) /* assign the group */ ob->dup_group = group; ob->transflag |= OB_DUPLIGROUP; - rename_id(&ob->id, group->id.name + 2); copy_v3_v3(ob->loc, scene->cursor); } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index c8862870b92..df985448ccd 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -799,4 +799,36 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + if (!MAIN_VERSION_ATLEAST(main, 274, 6)) { + bScreen *screen; + + if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) { + for (screen = main->screen.first; screen; screen = screen->id.next) { + ScrArea *sa; + + for (sa = screen->areabase.first; sa; sa = sa->next) { + SpaceLink *sl; + + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_FILE) { + SpaceFile *sfile = (SpaceFile *)sl; + + if (sfile->params) { + sfile->params->thumbnail_size = 128; + } + } + } + } + } + } + + if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) { + Scene *scene; + for (scene = main->scene.first; scene != NULL; scene = scene->id.next) { + scene->r.simplify_subsurf_render = scene->r.simplify_subsurf; + scene->r.simplify_particles_render = scene->r.simplify_particles; + } + } + } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 12c4f4922dc..285c50a4049 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1903,26 +1903,35 @@ static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count) { - CustomData data_tmp; int i; - /* This copy will automatically ignore/remove layers set as NO_COPY (and TEMPORARY). */ - CustomData_copy(data, &data_tmp, CD_MASK_EVERYTHING, CD_REFERENCE, count); + int nofree_buff[128]; + int *nofree; /* write external customdata (not for undo) */ - if (data_tmp.external && !wd->current) - CustomData_external_write(&data_tmp, id, CD_MASK_MESH, count, 0); + if (data->external && !wd->current) + CustomData_external_write(data, id, CD_MASK_MESH, count, 0); - for (i = 0; i < data_tmp.totlayer; i++) - data_tmp.layers[i].flag &= ~CD_FLAG_NOFREE; + if (data->totlayer > ARRAY_SIZE(nofree_buff)) { + nofree = MEM_mallocN(sizeof(*nofree) * (size_t)data->totlayer, __func__); + } + else { + nofree = nofree_buff; + } - writestruct_at_address(wd, DATA, "CustomDataLayer", data_tmp.maxlayer, data->layers, data_tmp.layers); + for (i = 0; i < data->totlayer; i++) { + nofree[i] = (data->layers[i].flag & CD_FLAG_NOFREE); + data->layers[i].flag &= ~CD_FLAG_NOFREE; + } + + writestruct(wd, DATA, "CustomDataLayer", data->maxlayer, data->layers); - for (i = 0; i < data_tmp.totlayer; i++) - data_tmp.layers[i].flag |= CD_FLAG_NOFREE; + for (i = 0; i < data->totlayer; i++) { + data->layers[i].flag |= nofree[i]; + } - for (i = 0; i < data_tmp.totlayer; i++) { - CustomDataLayer *layer= &data_tmp.layers[i]; + for (i = 0; i < data->totlayer; i++) { + CustomDataLayer *layer= &data->layers[i]; const char *structname; int structnum, datasize; @@ -1958,10 +1967,12 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, } } - if (data_tmp.external) - writestruct_at_address(wd, DATA, "CustomDataExternal", 1, data->external, data_tmp.external); + if (data->external) + writestruct(wd, DATA, "CustomDataExternal", 1, data->external); - CustomData_free(&data_tmp, count); + if (nofree != nofree_buff) { + MEM_freeN(nofree); + } } static void write_meshes(WriteData *wd, ListBase *idbase) @@ -1978,23 +1989,32 @@ static void write_meshes(WriteData *wd, ListBase *idbase) if (mesh->id.us>0 || wd->current) { /* write LibData */ if (!save_for_old_blender) { - -#ifdef USE_BMESH_SAVE_WITHOUT_MFACE /* write a copy of the mesh, don't modify in place because it is * not thread safe for threaded renders that are reading this */ Mesh *old_mesh = mesh; Mesh copy_mesh = *mesh; mesh = ©_mesh; +#ifdef USE_BMESH_SAVE_WITHOUT_MFACE /* cache only - don't write */ mesh->mface = NULL; mesh->totface = 0; memset(&mesh->fdata, 0, sizeof(mesh->fdata)); +#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */ + + /* Bummer! We need to do the copy *before* writing mesh's struct itself, + * because we eliminate NO_COPY & TEMPORARY layers here, which means + * **number of layers (data.totlayer) may be smaller!** + * If we do not do that, we can get crash by buffer-overflow on reading, see T44461. */ + CustomData_copy(&old_mesh->vdata, &mesh->vdata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totvert); + CustomData_copy(&old_mesh->edata, &mesh->edata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totedge); +#ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */ + CustomData_copy(&old_mesh->fdata, &mesh->fdata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totface); +#endif + CustomData_copy(&old_mesh->ldata, &mesh->ldata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totloop); + CustomData_copy(&old_mesh->pdata, &mesh->pdata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totpoly); writestruct_at_address(wd, ID_ME, "Mesh", 1, old_mesh, mesh); -#else - writestruct(wd, ID_ME, "Mesh", 1, mesh); -#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */ /* direct data */ if (mesh->id.properties) IDP_WriteProperty(mesh->id.properties, wd); @@ -2010,11 +2030,16 @@ static void write_meshes(WriteData *wd, ListBase *idbase) write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, -1, 0); write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, -1, 0); -#ifdef USE_BMESH_SAVE_WITHOUT_MFACE + CustomData_free(&mesh->vdata, mesh->totvert); + CustomData_free(&mesh->edata, mesh->totedge); +#ifndef USE_BMESH_SAVE_WITHOUT_MFACE + CustomData_free(&mesh->fdata, mesh->totface); +#endif + CustomData_free(&mesh->ldata, mesh->totloop); + CustomData_free(&mesh->pdata, mesh->totpoly); + /* restore pointer */ mesh = old_mesh; -#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */ - } else { @@ -2041,6 +2066,10 @@ static void write_meshes(WriteData *wd, ListBase *idbase) BKE_mesh_update_customdata_pointers(mesh, false); + /* See comment above. Note that loop/poly data are ignored here, and face ones are already handled. */ + CustomData_copy(&old_mesh->vdata, &mesh->vdata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totvert); + CustomData_copy(&old_mesh->edata, &mesh->edata, CD_MASK_EVERYTHING, CD_REFERENCE, mesh->totedge); + writestruct_at_address(wd, ID_ME, "Mesh", 1, old_mesh, mesh); /* direct data */ @@ -2059,6 +2088,8 @@ static void write_meshes(WriteData *wd, ListBase *idbase) write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, -1, 0); #endif + CustomData_free(&mesh->vdata, mesh->totvert); + CustomData_free(&mesh->edata, mesh->totedge); CustomData_free(&mesh->fdata, mesh->totface); /* restore pointer */ |