diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-06 02:24:05 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-06 02:24:05 +0400 |
commit | feccbaabbd39c18b2f552964ebd8dfab4eeaed89 (patch) | |
tree | 0069f654883a7a02dd320649ce61bd7933748111 /source/blender/blenloader | |
parent | a22096e8019c461128a0907e4026859996ec1b5c (diff) | |
parent | 37ba969c74840142682cf22f34610f3b65b86cf4 (diff) |
Merged changes in the trunk up to revision 53584.
Conflicts resolved:
release/scripts/startup/bl_ui/properties_render.py
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface_templates.c
source/blender/makesrna/RNA_enum_types.h
Also made additional code updates for:
r53355 UIList - Python-extendable list of UI items
r53460 Alpha premul pipeline cleanup
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 225 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.h | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_legacy.c | 12 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 45 |
6 files changed, 262 insertions, 36 deletions
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index e9caa337129..b2d37e36004 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -311,6 +311,9 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil /* makes lookup of existing video clips in old main */ blo_make_movieclip_pointer_map(fd, oldmain); + /* makes lookup of existing video clips in old main */ + blo_make_packed_pointer_map(fd, oldmain); + bfd = blo_read_file_internal(fd, filename); /* ensures relinked images are not freed */ @@ -319,6 +322,9 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil /* ensures relinked movie clips are not freed */ blo_end_movieclip_pointer_map(fd, oldmain); + /* ensures relinked packed data is not freed */ + blo_end_packed_pointer_map(fd, oldmain); + /* move libraries from old main to new main */ if (bfd && mainlist.first != mainlist.last) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4c3ba747906..151a929a445 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -546,7 +546,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab BLI_strncpy(name1, filepath, sizeof(name1)); cleanup_path(relabase, name1); -// printf("blo_find_main: original in %s\n", name); + +// printf("blo_find_main: relabase %s\n", relabase); +// printf("blo_find_main: original in %s\n", filepath); // printf("blo_find_main: converted to %s\n", name1); for (m = mainlist->first; m; m = m->next) { @@ -1023,6 +1025,46 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports) } } +static int fd_read_gzip_from_memory(FileData *filedata, void *buffer, unsigned int size) +{ + int err; + + filedata->strm.next_out = (Bytef *) buffer; + filedata->strm.avail_out = size; + + // Inflate another chunk. + err = inflate (&filedata->strm, Z_SYNC_FLUSH); + + if (err == Z_STREAM_END) { + return 0; + } + else if (err != Z_OK) { + printf("fd_read_gzip_from_memory: zlib error\n"); + return 0; + } + + filedata->seek += size; + + return (size); +} + +static int fd_read_gzip_from_memory_init(FileData *fd) +{ + + fd->strm.next_in = (Bytef *) fd->buffer; + fd->strm.avail_in = fd->buffersize; + fd->strm.total_out = 0; + fd->strm.zalloc = Z_NULL; + fd->strm.zfree = Z_NULL; + + if (inflateInit2(&fd->strm, (16+MAX_WBITS)) != Z_OK) + return 0; + + fd->read = fd_read_gzip_from_memory; + + return 1; +} + FileData *blo_openblendermemory(void *mem, int memsize, ReportList *reports) { if (!mem || memsize<SIZEOFBLENDERHEADER) { @@ -1031,9 +1073,21 @@ FileData *blo_openblendermemory(void *mem, int memsize, ReportList *reports) } else { FileData *fd = filedata_new(); + char *cp = mem; + fd->buffer = mem; fd->buffersize = memsize; + + /* test if gzip */ + if (cp[0] == 0x1f && cp[1] == 0x8b) { + if (0 == fd_read_gzip_from_memory_init(fd)) { + blo_freefiledata(fd); + return NULL; + } + } + else fd->read = fd_read_from_memory; + fd->flags |= FD_FLAGS_NOT_MY_BUFFER; return blo_decode_and_check(fd, reports); @@ -1069,6 +1123,12 @@ void blo_freefiledata(FileData *fd) gzclose(fd->gzfiledes); } + if (fd->strm.next_in) { + if (inflateEnd (&fd->strm) != Z_OK) { + printf("close gzip stream error\n"); + } + } + if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) { MEM_freeN(fd->buffer); fd->buffer = NULL; @@ -1092,6 +1152,8 @@ void blo_freefiledata(FileData *fd) oldnewmap_free(fd->imamap); if (fd->movieclipmap) oldnewmap_free(fd->movieclipmap); + if (fd->packedmap) + oldnewmap_free(fd->packedmap); if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP)) oldnewmap_free(fd->libmap); if (fd->bheadmap) @@ -1176,6 +1238,14 @@ static void *newmclipadr(FileData *fd, void *adr) /* used to restor return NULL; } +static void *newpackedadr(FileData *fd, void *adr) /* used to restore packed data after undo */ +{ + if (fd->packedmap && adr) + return oldnewmap_lookup_and_inc(fd->packedmap, adr); + + return oldnewmap_lookup_and_inc(fd->datamap, adr); +} + static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */ { @@ -1372,6 +1442,69 @@ void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain) } } +static void insert_packedmap(FileData *fd, PackedFile *pf) +{ + oldnewmap_insert(fd->packedmap, pf, pf, 0); + oldnewmap_insert(fd->packedmap, pf->data, pf->data, 0); +} + +void blo_make_packed_pointer_map(FileData *fd, Main *oldmain) +{ + Image *ima; + VFont *vfont; + bSound *sound; + Library *lib; + + fd->packedmap = oldnewmap_new(); + + for (ima = oldmain->image.first; ima; ima = ima->id.next) + if (ima->packedfile) + insert_packedmap(fd, ima->packedfile); + + for (vfont = oldmain->vfont.first; vfont; vfont = vfont->id.next) + if (vfont->packedfile) + insert_packedmap(fd, vfont->packedfile); + + for (sound = oldmain->sound.first; sound; sound = sound->id.next) + if (sound->packedfile) + insert_packedmap(fd, sound->packedfile); + + for (lib = oldmain->library.first; lib; lib = lib->id.next) + if (lib->packedfile) + insert_packedmap(fd, lib->packedfile); + +} + +/* set old main packed data to zero if it has been restored */ +/* this works because freeing old main only happens after this call */ +void blo_end_packed_pointer_map(FileData *fd, Main *oldmain) +{ + Image *ima; + VFont *vfont; + bSound *sound; + Library *lib; + OldNew *entry = fd->packedmap->entries; + int i; + + /* used entries were restored, so we put them to zero */ + for (i=0; i < fd->packedmap->nentries; i++, entry++) { + if (entry->nr > 0) + entry->newp = NULL; + } + + for (ima = oldmain->image.first; ima; ima = ima->id.next) + ima->packedfile = newpackedadr(fd, ima->packedfile); + + for (vfont = oldmain->vfont.first; vfont; vfont = vfont->id.next) + vfont->packedfile = newpackedadr(fd, vfont->packedfile); + + for (sound = oldmain->sound.first; sound; sound = sound->id.next) + sound->packedfile = newpackedadr(fd, sound->packedfile); + + for (lib = oldmain->library.first; lib; lib = lib->id.next) + lib->packedfile = newpackedadr(fd, lib->packedfile); +} + /* undo file support: add all library pointers in lookup */ void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd) @@ -1711,10 +1844,10 @@ static void direct_link_script(FileData *UNUSED(fd), Script *script) static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf) { - PackedFile *pf = newdataadr(fd, oldpf); + PackedFile *pf = newpackedadr(fd, oldpf); if (pf) { - pf->data = newdataadr(fd, pf->data); + pf->data = newpackedadr(fd, pf->data); } return pf; @@ -2538,7 +2671,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) cld.fd = fd; cld.id = id; - id_loop_constraints(conlist, lib_link_constraint_cb, &cld); + BKE_id_loop_constraints(conlist, lib_link_constraint_cb, &cld); } static void direct_link_constraints(FileData *fd, ListBase *lb) @@ -5725,6 +5858,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) { Panel *pa; + uiList *ui_list; link_list(fd, &ar->panels); @@ -5735,6 +5869,12 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) pa->type = NULL; } + link_list(fd, &ar->ui_lists); + + for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) { + ui_list->type = NULL; + } + ar->regiondata = newdataadr(fd, ar->regiondata); if (ar->regiondata) { if (spacetype == SPACE_VIEW3D) { @@ -6057,6 +6197,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) { Main *newmain; + /* check if the library was already read */ for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) { if (newmain->curlib) { if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) { @@ -6075,14 +6216,14 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) } } } - /* make sure we have full path in lib->filename */ + /* make sure we have full path in lib->filepath */ BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name)); cleanup_path(fd->relabase, lib->filepath); -#if 0 - printf("direct_link_library: name %s\n", lib->name); - printf("direct_link_library: filename %s\n", lib->filename); -#endif +// printf("direct_link_library: name %s\n", lib->name); +// printf("direct_link_library: filepath %s\n", lib->filepath); + + lib->packedfile = direct_link_packedfile(fd, lib->packedfile); /* new main */ newmain= MEM_callocN(sizeof(Main), "directlink"); @@ -7713,7 +7854,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for (ob = main->object.first; ob; ob = ob->id.next) { bConstraint *con; for (con = ob->constraints.first; con; con = con->next) { - bConstraintTypeInfo *cti = constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con); if (!cti) continue; @@ -8636,15 +8777,41 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - { + if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 5)) { Scene *scene; + Image *image; + Tex *tex; for (scene = main->scene.first; scene; scene = scene->id.next) { + Sequence *seq; + + SEQ_BEGIN (scene->ed, seq) + { + if (seq->flag & SEQ_MAKE_PREMUL) + seq->alpha_mode = SEQ_ALPHA_STRAIGHT; + } + SEQ_END + if (scene->r.bake_samples == 0) scene->r.bake_samples = 256; } + + for (image = main->image.first; image; image = image->id.next) { + if (image->flag & IMA_DO_PREMUL) + image->alpha_mode = IMA_ALPHA_STRAIGHT; } + for (tex = main->tex.first; tex; tex = tex->id.next) { + if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) { + image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima); + + if (image) + image->flag |= IMA_IGNORE_ALPHA; + } + } + } + + #ifdef WITH_FREESTYLE /* default values in Freestyle settings */ { @@ -8759,6 +8926,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) wmKeyMap *keymap; wmKeyMapItem *kmi; wmKeyMapDiffItem *kmdi; + bAddon *addon; bfd->user = user= read_struct(fd, bhead, "user def"); @@ -8797,6 +8965,13 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) direct_link_keymapitem(fd, kmi); } + for (addon = user->addons.first; addon; addon = addon->next) { + addon->prop = newdataadr(fd, addon->prop); + if (addon->prop) { + IDP_DirectLinkProperty(addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + } + } + // XXX user->uifonts.first = user->uifonts.last= NULL; @@ -9001,6 +9176,14 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) Library *lib = read_struct(fd, bheadlib, "Library"); Main *ptr = blo_find_main(fd, lib->name, fd->relabase); + if (ptr->curlib == NULL) { + const char *idname= bhead_id_name(fd, bhead); + + BKE_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB ERROR: Data refers to main .blend file: '%s' from %s"), + idname, mainvar->curlib->filepath); + return; + } + else id = is_yet_read(fd, ptr, bhead); if (id == NULL) { @@ -9440,7 +9623,7 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb) ced.fd = fd; ced.mainvar = mainvar; - id_loop_constraints(lb, expand_constraint_cb, &ced); + BKE_id_loop_constraints(lb, expand_constraint_cb, &ced); /* deprecated manual expansion stuff */ for (curcon = lb->first; curcon; curcon = curcon->next) { @@ -10299,12 +10482,26 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) FileData *fd = mainptr->curlib->filedata; if (fd == NULL) { + /* printf and reports for now... its important users know this */ + + /* if packed file... */ + if (mainptr->curlib->packedfile) { + PackedFile *pf = mainptr->curlib->packedfile; + + BKE_reportf_wrap(basefd->reports, RPT_INFO, TIP_("Read packed library: '%s'"), + mainptr->curlib->name); + fd = blo_openblendermemory(pf->data, pf->size, basefd->reports); + + + /* needed for library_append and read_libraries */ + BLI_strncpy(fd->relabase, mainptr->curlib->filepath, sizeof(fd->relabase)); + } + else { BKE_reportf_wrap(basefd->reports, RPT_INFO, TIP_("Read library: '%s', '%s'"), mainptr->curlib->filepath, mainptr->curlib->name); - fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports); - + } /* allow typing in a new lib path */ if (G.debug_value == -666) { while (fd == NULL) { diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index a979a16220d..a0895c92b24 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -69,6 +69,9 @@ typedef struct FileData { char headerdone; int inbuffer; + // gzip stream for memory decompression + z_stream strm; + // general reading variables struct SDNA *filesdna; struct SDNA *memsdna; @@ -83,6 +86,7 @@ typedef struct FileData { struct OldNewMap *libmap; struct OldNewMap *imamap; struct OldNewMap *movieclipmap; + struct OldNewMap *packedmap; struct BHeadSort *bheadmap; int tot_bheadmap; @@ -127,6 +131,8 @@ void blo_make_image_pointer_map(FileData *fd, Main *oldmain); void blo_end_image_pointer_map(FileData *fd, Main *oldmain); void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain); void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain); +void blo_make_packed_pointer_map(FileData *fd, Main *oldmain); +void blo_end_packed_pointer_map(FileData *fd, Main *oldmain); void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd); void blo_freefiledata(FileData *fd); diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 1521739258e..f4d841fd22a 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -292,7 +292,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) memcpy(&ar->v2d, &soops->v2d, sizeof(View2D)); ar->v2d.scroll &= ~V2D_SCROLL_LEFT; - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); + ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); ar->v2d.keeptot = V2D_KEEPTOT_STRICT; @@ -415,7 +415,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.tot.ymax = ar->winy; ar->v2d.cur = ar->v2d.tot; ar->regiontype = RGN_TYPE_WINDOW; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); break; diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 8a56e3c2ab8..65a60e11ab3 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -289,11 +289,10 @@ static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) iuser = node->storage; if (iuser->flag & IMA_OLD_PREMUL) { iuser->flag &= ~IMA_OLD_PREMUL; - iuser->flag |= IMA_DO_PREMUL; } if (iuser->flag & IMA_DO_PREMUL) { image->flag &= ~IMA_OLD_PREMUL; - image->flag |= IMA_DO_PREMUL; + image->alpha_mode = IMA_ALPHA_STRAIGHT; } } } @@ -545,7 +544,7 @@ void blo_do_version_old_trackto_to_constraints(Object *ob) { /* create new trackto constraint from the relationship */ if (ob->track) { - bConstraint *con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); + bConstraint *con = BKE_add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); bTrackToConstraint *data = con->data; /* copy tracking settings from the object */ @@ -1840,7 +1839,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) SEQ_BEGIN (sce->ed, seq) { if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE) - seq->flag |= SEQ_MAKE_PREMUL; + seq->alpha_mode = SEQ_ALPHA_STRAIGHT; } SEQ_END } @@ -2901,20 +2900,19 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) for (ima = main->image.first; ima; ima = ima->id.next) { if (ima->flag & IMA_OLD_PREMUL) { ima->flag &= ~IMA_OLD_PREMUL; - ima->flag |= IMA_DO_PREMUL; + ima->alpha_mode = IMA_ALPHA_STRAIGHT; } } for (tex = main->tex.first; tex; tex = tex->id.next) { if (tex->iuser.flag & IMA_OLD_PREMUL) { tex->iuser.flag &= ~IMA_OLD_PREMUL; - tex->iuser.flag |= IMA_DO_PREMUL; } ima = blo_do_versions_newlibadr(fd, lib, tex->ima); if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) { ima->flag &= ~IMA_OLD_PREMUL; - ima->flag |= IMA_DO_PREMUL; + ima->alpha_mode = IMA_ALPHA_STRAIGHT; } } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 3f80674bf60..b1aee9f498a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -853,8 +853,12 @@ static void write_userdef(WriteData *wd) write_keymapitem(wd, kmi); } - for (bext= U.addons.first; bext; bext=bext->next) + for (bext= U.addons.first; bext; bext=bext->next) { writestruct(wd, DATA, "bAddon", 1, bext); + if (bext->prop) { + IDP_WriteProperty(bext->prop, wd); + } + } for (style= U.uistyles.first; style; style= style->next) { writestruct(wd, DATA, "uiStyle", 1, style); @@ -1231,7 +1235,7 @@ static void write_constraints(WriteData *wd, ListBase *conlist) bConstraint *con; for (con=conlist->first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti= BKE_constraint_get_typeinfo(con); /* Write the specific data */ if (cti && con->data) { @@ -1511,7 +1515,7 @@ static void write_vfonts(WriteData *wd, ListBase *idbase) /* direct data */ - if (vf->packedfile) { + if (vf->packedfile && !wd->current) { pf = vf->packedfile; writestruct(wd, DATA, "PackedFile", 1, pf); writedata(wd, DATA, pf->size, pf->data); @@ -1961,7 +1965,7 @@ static void write_images(WriteData *wd, ListBase *idbase) writestruct(wd, ID_IM, "Image", 1, ima); if (ima->id.properties) IDP_WriteProperty(ima->id.properties, wd); - if (ima->packedfile) { + if (ima->packedfile && !wd->current) { pf = ima->packedfile; writestruct(wd, DATA, "PackedFile", 1, pf); writedata(wd, DATA, pf->size, pf->data); @@ -2415,6 +2419,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase) for (sa= sc->areabase.first; sa; sa= sa->next) { SpaceLink *sl; Panel *pa; + uiList *ui_list; ARegion *ar; writestruct(wd, DATA, "ScrArea", 1, sa); @@ -2424,6 +2429,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase) for (pa= ar->panels.first; pa; pa= pa->next) writestruct(wd, DATA, "Panel", 1, pa); + + for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) + writestruct(wd, DATA, "uiList", 1, ui_list); } sl= sa->spacedata.first; @@ -2551,20 +2559,31 @@ static void write_libraries(WriteData *wd, Main *main) a=tot= set_listbasepointers(main, lbarray); /* test: is lib being used */ - foundone = FALSE; - while (tot--) { - for (id= lbarray[tot]->first; id; id= id->next) { - if (id->us>0 && (id->flag & LIB_EXTERN)) { - foundone = TRUE; - break; + if (main->curlib && main->curlib->packedfile) + foundone = TRUE; + else { + foundone = FALSE; + while (tot--) { + for (id= lbarray[tot]->first; id; id= id->next) { + if (id->us>0 && (id->flag & LIB_EXTERN)) { + foundone = TRUE; + break; + } } + if (foundone) break; } - if (foundone) break; } - + if (foundone) { writestruct(wd, ID_LI, "Library", 1, main->curlib); + if (main->curlib->packedfile && !wd->current) { + PackedFile *pf = main->curlib->packedfile; + writestruct(wd, DATA, "PackedFile", 1, pf); + writedata(wd, DATA, pf->size, pf->data); + printf("write packed .blend: %s\n", main->curlib->name); + } + while (a--) { for (id= lbarray[a]->first; id; id= id->next) { if (id->us>0 && (id->flag & LIB_EXTERN)) { @@ -2693,7 +2712,7 @@ static void write_sounds(WriteData *wd, ListBase *idbase) writestruct(wd, ID_SO, "bSound", 1, sound); if (sound->id.properties) IDP_WriteProperty(sound->id.properties, wd); - if (sound->packedfile) { + if (sound->packedfile && !wd->current) { pf = sound->packedfile; writestruct(wd, DATA, "PackedFile", 1, pf); writedata(wd, DATA, pf->size, pf->data); |