From c52c10d1781825290d56d27551b6a51b4ab85b40 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Oct 2010 21:25:05 +0000 Subject: append was using a freed Main pointer to refer to the curlib when instancing group objects and centering objects around the cursor. --- source/blender/blenloader/intern/readfile.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f24de9c605d..0eb25a6b894 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12433,25 +12433,29 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in { Main *mainvar= CTX_data_main(C); Scene *scene= CTX_data_scene(C); + Library *curlib; /* make main consistent */ expand_main(*fd, mainl); /* do this when expand found other libs */ read_libraries(*fd, &(*fd)->mainlist); + + curlib= mainl->curlib; /* make the lib path relative if required */ if(flag & FILE_RELPATH) { /* use the full path, this could have been read by other library even */ - BLI_strncpy(mainl->curlib->name, mainl->curlib->filepath, sizeof(mainl->curlib->name)); + BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name)); /* uses current .blend file as reference */ - BLI_path_rel(mainl->curlib->name, G.sce); + BLI_path_rel(curlib->name, G.sce); } blo_join_main(&(*fd)->mainlist); mainvar= (*fd)->mainlist.first; + mainl= NULL; /* blo_join_main free's mainl, cant use anymore */ lib_link_all(*fd, mainvar); lib_verify_nodetree(mainvar, 0); @@ -12466,7 +12470,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in if (flag & FILE_LINK) { give_base_to_objects(mainvar, scene, NULL, 0); } else { - give_base_to_objects(mainvar, scene, mainl->curlib, 1); + give_base_to_objects(mainvar, scene, curlib, 1); } if (flag & FILE_GROUP_INSTANCE) { @@ -12486,7 +12490,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in *fd = NULL; } - append_do_cursor(scene, mainl->curlib, flag); + append_do_cursor(scene, curlib, flag); } void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag) -- cgit v1.2.3