From b299b039f7d0f0baa65242f918066cdc808a71ce Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 6 May 2013 11:23:13 +0000 Subject: Bug fix #35179 Added provision for saved corrupt blend files - caused by a startup.blend addressing > 16 GB space, which was read in 32 bits. Now an invalid screen will get removed immediate after read. Might give a memory-not-in-memlist print, but that's quite safe. --- source/blender/blenloader/intern/readfile.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 78fcc22ea66..4062f57d4eb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6148,11 +6148,12 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) v3d->twtype = V3D_MANIP_TRANSLATE; } -static void direct_link_screen(FileData *fd, bScreen *sc) +static bool direct_link_screen(FileData *fd, bScreen *sc) { ScrArea *sa; ScrVert *sv; ScrEdge *se; + bool wrong_id = false; link_list(fd, &(sc->vertbase)); link_list(fd, &(sc->edgebase)); @@ -6174,8 +6175,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } if (se->v1 == NULL) { - printf("error reading screen... file corrupt\n"); - se->v1 = se->v2; + printf("Error reading Screen %s... removing it.\n", sc->id.name+2); + wrong_id = true; } } @@ -6409,6 +6410,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc) sa->v3 = newdataadr(fd, sa->v3); sa->v4 = newdataadr(fd, sa->v4); } + + return wrong_id; } /* ********** READ LIBRARY *************** */ @@ -7016,6 +7019,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID ID *id; ListBase *lb; const char *allocname; + bool wrong_id; /* read libblock */ id = read_struct(fd, bhead, "lib block"); @@ -7063,7 +7067,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID direct_link_windowmanager(fd, (wmWindowManager *)id); break; case ID_SCR: - direct_link_screen(fd, (bScreen *)id); + wrong_id = direct_link_screen(fd, (bScreen *)id); break; case ID_SCE: direct_link_scene(fd, (Scene *)id); @@ -7160,6 +7164,10 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID oldnewmap_free_unused(fd->datamap); oldnewmap_clear(fd->datamap); + if (wrong_id) { + BKE_libblock_free(lb, id); + } + return (bhead); } -- cgit v1.2.3