[#13726] Segfault with (Re)Appending objects

fix this by freeing the lib-file-data after linking or appending, re-appending will be slower now
(as slow as appending for the first time).

Not strictly needed, set the memory for bhead's to zero in readfile.c since comparisons are done later on with this data making valgrind complain.

Added some missing headers too.
This commit is contained in:
Campbell Barton 2009-05-12 15:28:07 +00:00
parent 732c3ee66f
commit b6fa9afccb
3 changed files with 12 additions and 0 deletions

@ -36,6 +36,8 @@
#include "DNA_particle_types.h"
#include "DNA_scene_types.h" // N_T
#include "PIL_time.h" // for PIL_sleep_ms
#include "BLI_arithb.h"
#include "BLI_blenlib.h"

@ -133,6 +133,7 @@
#include "BKE_main.h" // for Main
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_multires.h" // for multires_free
#include "BKE_node.h" // for tree type defines
#include "BKE_object.h"
#include "BKE_particle.h"
@ -617,6 +618,11 @@ static BHeadN *get_bhead(FileData *fd)
BHeadN *new_bhead = 0;
int readsize;
/* not strictly needed but shuts valgrind up
* since uninitialized memory gets compared */
memset(&bhead8, 0, sizeof(BHead8));
memset(&bhead4, 0, sizeof(BHead4));
if (fd) {
if ( ! fd->eof) {
@ -9233,6 +9239,8 @@ void BLO_script_library_append(BlendHandle **bh, char *dir, char *name,
void BLO_library_append(SpaceFile *sfile, char *dir, int idcode)
{
BLO_library_append_(&sfile->libfiledata, sfile->filelist, sfile->totfile, dir, sfile->file, sfile->flag, idcode);
BLO_blendhandle_close(sfile->libfiledata);
sfile->libfiledata= NULL;
}
void BLO_library_append_(BlendHandle** libfiledata, struct direntry* filelist, int totfile, char *dir, char* file, short flag, int idcode)

@ -913,6 +913,8 @@ void BIF_filelist_from_library(struct FileList* filelist)
void BIF_filelist_append_library(struct FileList *filelist, char *dir, char *file, short flag, int idcode)
{
BLO_library_append_(&filelist->libfiledata, filelist->filelist, filelist->numfiles, dir, file, flag, idcode);
BLO_blendhandle_close(filelist->libfiledata);
filelist->libfiledata= NULL;
}
void BIF_filelist_from_main(struct FileList *filelist)