diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-06-04 13:05:11 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-06-04 13:05:11 +0300 |
commit | 343c4fb54a514b55a9d0e01fc1275fa66bf1fbca (patch) | |
tree | 78ab1fd1f77af1c467e98cc31e940845e0737aee /source/blender/blenloader/intern | |
parent | 44276743cfb31996f90a19c6d98839bea3cc1ce4 (diff) | |
parent | cf7a5e93f8d89d8b5382b07834dd0e9fc694254b (diff) |
Merge branch 'master' into gooseberry
Conflicts:
intern/cycles/kernel/svm/svm.h
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 24 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 21 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 2 |
3 files changed, 35 insertions, 12 deletions
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 95440158277..20ec27a1f4b 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -176,26 +176,38 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to prv = BLO_library_read_struct(fd, bhead, "PreviewImage"); if (prv) { memcpy(new_prv, prv, sizeof(PreviewImage)); - if (prv->rect[0]) { + if (prv->rect[0] && prv->w[0] && prv->h[0]) { unsigned int *rect = NULL; - new_prv->rect[0] = MEM_callocN(new_prv->w[0] * new_prv->h[0] * sizeof(unsigned int), "prvrect"); + size_t len = new_prv->w[0] * new_prv->h[0] * sizeof(unsigned int); + new_prv->rect[0] = MEM_callocN(len, __func__); bhead = blo_nextbhead(fd, bhead); rect = (unsigned int *)(bhead + 1); - memcpy(new_prv->rect[0], rect, bhead->len); + BLI_assert(len == bhead->len); + memcpy(new_prv->rect[0], rect, len); } else { + /* This should not be needed, but can happen in 'broken' .blend files, + * better handle this gracefully than crashing. */ + BLI_assert(prv->rect[0] == NULL && prv->w[0] == 0 && prv->h[0] == 0); new_prv->rect[0] = NULL; + new_prv->w[0] = new_prv->h[0] = 0; } - if (prv->rect[1]) { + if (prv->rect[1] && prv->w[1] && prv->h[1]) { unsigned int *rect = NULL; - new_prv->rect[1] = MEM_callocN(new_prv->w[1] * new_prv->h[1] * sizeof(unsigned int), "prvrect"); + size_t len = new_prv->w[1] * new_prv->h[1] * sizeof(unsigned int); + new_prv->rect[1] = MEM_callocN(len, __func__); bhead = blo_nextbhead(fd, bhead); rect = (unsigned int *)(bhead + 1); - memcpy(new_prv->rect[1], rect, bhead->len); + BLI_assert(len == bhead->len); + memcpy(new_prv->rect[1], rect, len); } else { + /* This should not be needed, but can happen in 'broken' .blend files, + * better handle this gracefully than crashing. */ + BLI_assert(prv->rect[1] == NULL && prv->w[1] == 0 && prv->h[1] == 0); new_prv->rect[1] = NULL; + new_prv->w[1] = new_prv->h[1] = 0; } MEM_freeN(prv); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c7d0cf99904..1edd694f935 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1539,6 +1539,10 @@ void blo_make_packed_pointer_map(FileData *fd, Main *oldmain) for (ima = oldmain->image.first; ima; ima = ima->id.next) { ImagePackedFile *imapf; + + if (ima->packedfile) + insert_packedmap(fd, ima->packedfile); + for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) if (imapf->packedfile) insert_packedmap(fd, imapf->packedfile); @@ -1577,6 +1581,9 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain) for (ima = oldmain->image.first; ima; ima = ima->id.next) { ImagePackedFile *imapf; + + ima->packedfile = newpackedadr(fd, ima->packedfile); + for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) imapf->packedfile = newpackedadr(fd, imapf->packedfile); } @@ -2081,7 +2088,7 @@ static void direct_link_cache_library(FileData *fd, CacheLibrary *cachelib) static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf) { PackedFile *pf = newpackedadr(fd, oldpf); - + if (pf) { pf->data = newpackedadr(fd, pf->data); } @@ -3528,13 +3535,17 @@ static void direct_link_image(FileData *fd, Image *ima) link_list(fd, &(ima->views)); link_list(fd, &(ima->packedfiles)); - ima->packedfile = NULL; - for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { - imapf->packedfile = direct_link_packedfile(fd, imapf->packedfile); + if (ima->packedfiles.first) { + for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { + imapf->packedfile = direct_link_packedfile(fd, imapf->packedfile); + } + ima->packedfile = NULL; + } + else { + ima->packedfile = direct_link_packedfile(fd, ima->packedfile); } ima->anims.first = ima->anims.last = NULL; - ima->packedfile = direct_link_packedfile(fd, ima->packedfile); ima->preview = direct_link_preview_image(fd, ima->preview); ima->stereo3d_format = newdataadr(fd, ima->stereo3d_format); ima->ok = 1; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 274fc474ade..2727f3a3965 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -766,7 +766,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bSoundActuator *sAct = (bSoundActuator*) act->data; if (sAct->sound) { sound = blo_do_versions_newlibadr(fd, lib, sAct->sound); - sAct->flag = sound->flags & SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0; + sAct->flag = (sound->flags & SOUND_FLAGS_3D) ? ACT_SND_3D_SOUND : 0; sAct->pitch = sound->pitch; sAct->volume = sound->volume; sAct->sound3D.reference_distance = sound->distance; |