Images: Solve broken forward compatibility with packed images
Use first packed image as legacy image->packedfile, so saving .blend file with latest builds makes it so packed images are not lost when opening with previous releases. This will only work reliably if mutliview is not used, otherwise it'll be only first view in the .blend file, which is rather expected since previous releases are not aware of views.
This commit is contained in:
@@ -1536,9 +1536,6 @@ 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,8 +1574,6 @@ 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);
|
||||
}
|
||||
@@ -3437,6 +3432,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -2161,6 +2161,13 @@ static void write_images(WriteData *wd, ListBase *idbase)
|
||||
ima= idbase->first;
|
||||
while (ima) {
|
||||
if (ima->id.us>0 || wd->current) {
|
||||
/* Some trickery to keep forward compatibility of packed images. */
|
||||
BLI_assert(ima->packedfile == NULL);
|
||||
if (ima->packedfiles.first != NULL) {
|
||||
imapf = ima->packedfiles.first;
|
||||
ima->packedfile = imapf->packedfile;
|
||||
}
|
||||
|
||||
/* write LibData */
|
||||
writestruct(wd, ID_IM, "Image", 1, ima);
|
||||
if (ima->id.properties) IDP_WriteProperty(ima->id.properties, wd);
|
||||
@@ -2179,6 +2186,8 @@ static void write_images(WriteData *wd, ListBase *idbase)
|
||||
for (iv = ima->views.first; iv; iv = iv->next)
|
||||
writestruct(wd, DATA, "ImageView", 1, iv);
|
||||
writestruct(wd, DATA, "Stereo3dFormat", 1, ima->stereo3d_format);
|
||||
|
||||
ima->packedfile = NULL;
|
||||
}
|
||||
ima= ima->id.next;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ typedef struct Image {
|
||||
unsigned int bindcode; /* only for current image... */
|
||||
unsigned int *repbind; /* for repeat of parts of images */
|
||||
|
||||
struct PackedFile *packedfile; /* deprecated */
|
||||
struct PackedFile *packedfile DNA_DEPRECATED; /* deprecated */
|
||||
struct ListBase packedfiles;
|
||||
struct PreviewImage *preview;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user