Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-20 20:43:25 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-20 20:43:25 +0400
commit5e5a38cdc3f4983eb17588fcaa1c4a44dbb20892 (patch)
treefbbb75fe52845d3b10ac28ba0b7321c398410d6a /source/blender
parent9a00cc55c170cfca5718d89fc8a2036fe05155b1 (diff)
Bugfixes for quit.blend + library linking, the last commit didn't solve
that completely: * quit.blend is saved from the undo file, which did not save out library ID_LI and ID_ID blocks, for quick undo keeping the library datablocks. However this means library links are lost on reading the quit.blend, so now instead of not writing them, they are not read on undo. * Libraries were not not using the right path yet always. Note the screen setup is still not recovered from the quit.blend if no auto save happened yet, but that is not important enough to spend time on now.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/readblenentry.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c37
-rw-r--r--source/blender/blenloader/intern/readfile.h2
-rw-r--r--source/blender/blenloader/intern/writefile.c3
4 files changed, 30 insertions, 14 deletions
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 3d21bb54e2b..7608f988f4f 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -364,7 +364,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
fd = blo_openblendermemfile(memfile, reports);
if (fd) {
fd->reports= reports;
- strcpy(fd->filename, filename);
+ strcpy(fd->relabase, filename);
/* clear ob->proxy_from pointers in old main */
blo_clear_proxy_pointers_from_lib(fd, oldmain);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index ca2e5f4de75..6601d9c3fe2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -977,7 +977,7 @@ FileData *blo_openblenderfile(char *name, ReportList *reports)
fd->read = fd_read_gzip_from_file;
/* needed for library_append and read_libraries */
- BLI_strncpy(fd->filename, name, sizeof(fd->filename));
+ BLI_strncpy(fd->relabase, name, sizeof(fd->relabase));
return blo_decode_and_check(fd, reports);
}
@@ -5134,7 +5134,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
}
/* make sure we have full path in lib->filename */
BLI_strncpy(lib->filename, lib->name, sizeof(lib->name));
- cleanup_path(fd->filename, lib->filename);
+ cleanup_path(fd->relabase, lib->filename);
// printf("direct_link_library: name %s\n", lib->name);
// printf("direct_link_library: filename %s\n", lib->filename);
@@ -5469,6 +5469,8 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
bfd->displaymode= fg->displaymode;
bfd->globalf= fg->globalf;
BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
+ if(G.fileflags & G_FILE_RECOVER)
+ BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
bfd->curscreen= fg->curscreen;
bfd->curscene= fg->curscene;
@@ -6284,7 +6286,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* WATCH IT!!!: pointers from libdata have not been converted */
if(G.f & G_DEBUG)
- printf("read file %s\n Version %d sub %d\n", fd->filename, main->versionfile, main->subversionfile);
+ printf("read file %s\n Version %d sub %d\n", fd->relabase, main->versionfile, main->subversionfile);
if(main->versionfile == 100) {
/* tex->extend and tex->imageflag have changed: */
@@ -10058,14 +10060,25 @@ BlendFileData *blo_read_file_internal(FileData *fd, char *file)
break;
case ID_LI:
- bhead = read_libblock(fd, bfd->main, bhead, LIB_LOCAL, NULL);
+ /* skip library datablocks in undo, this works together with
+ BLO_read_from_memfile, where the old main->library is restored
+ overwriting the libraries from the memory file. previously
+ it did not save ID_LI/ID_ID blocks in this case, but they are
+ needed to make quit.blend recover them correctly. */
+ if(fd->memfile)
+ bhead= blo_nextbhead(fd, bhead);
+ else
+ bhead= read_libblock(fd, bfd->main, bhead, LIB_LOCAL, NULL);
break;
case ID_ID:
+ /* same as above */
+ if(fd->memfile)
+ bhead= blo_nextbhead(fd, bhead);
+ else
/* always adds to the most recently loaded
* ID_LI block, see direct_link_library.
- * this is part of the file format definition.
- */
- bhead = read_libblock(fd, fd->mainlist.last, bhead, LIB_READ+LIB_EXTERN, NULL);
+ * this is part of the file format definition. */
+ bhead = read_libblock(fd, fd->mainlist.last, bhead, LIB_READ+LIB_EXTERN, NULL);
break;
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
@@ -10087,7 +10100,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, char *file)
lib_link_all(fd, bfd->main);
lib_verify_nodetree(bfd->main, 1);
- fix_relpaths_library(fd->filename, bfd->main); /* make all relative paths, relative to the open blend file */
+ fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */
link_global(fd, bfd); /* as last */
@@ -10135,6 +10148,10 @@ static void sort_bhead_old_map(FileData *fd)
static BHead *find_previous_lib(FileData *fd, BHead *bhead)
{
+ /* skip library datablocks in undo, see comment in read_libblock */
+ if(fd->memfile)
+ return NULL;
+
for (; bhead; bhead= blo_prevbhead(fd, bhead))
if (bhead->code==ID_LI)
break;
@@ -10206,7 +10223,7 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
if(bheadlib) {
Library *lib= read_struct(fd, bheadlib, "Library");
- Main *ptr= blo_find_main(fd, &fd->mainlist, lib->name, fd->filename);
+ Main *ptr= blo_find_main(fd, &fd->mainlist, lib->name, fd->relabase);
id= is_yet_read(fd, ptr, bhead);
@@ -11464,7 +11481,7 @@ BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize,
fd->read = fd_read_from_file;
/* needed for library_append and read_libraries */
- BLI_strncpy(fd->filename, name, sizeof(fd->filename));
+ BLI_strncpy(fd->relabase, name, sizeof(fd->relabase));
fd = blo_decode_and_check(fd, reports);
if (!fd)
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 2a0b6c327d3..41bc8f80fec 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -56,7 +56,7 @@ typedef struct FileData {
gzFile gzfiledes;
// now only in use for library appending
- char filename[FILE_MAXDIR+FILE_MAXFILE];
+ char relabase[FILE_MAXDIR+FILE_MAXFILE];
// variables needed for reading from stream
char headerdone;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index f0c584b6267..7368663f64a 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2383,8 +2383,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
write_brushes (wd, &mainvar->brush);
write_scripts (wd, &mainvar->script);
write_gpencils (wd, &mainvar->gpencil);
- if(current==NULL)
- write_libraries(wd, mainvar->next); /* no library save in undo */
+ write_libraries(wd, mainvar->next);
if (write_user_block) {
write_userdef(wd);